mirror of https://github.com/apache/activemq.git
added initial spike of using Protocol Buffer as the wire format for https://issues.apache.org/activemq/browse/AMQ-1843
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@674837 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f0ae093a12
commit
f9b668b05b
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
mkdir -p target/generated-source
|
||||
protoc -I=src/main/proto --java_out=src/main/java src/main/proto/openwire.proto
|
|
@ -0,0 +1,79 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.apache.activemq</groupId>
|
||||
<artifactId>activemq-parent</artifactId>
|
||||
<version>5.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>activemq-protocol-buffer</artifactId>
|
||||
<packaging>bundle</packaging>
|
||||
<name>ActiveMQ :: Protocol Buffer</name>
|
||||
<description>ActiveMQ Protocol Buffer</description>
|
||||
|
||||
<properties>
|
||||
<activemq.osgi.import.pkg>
|
||||
org.apache.activemq*;resolution:=optional,
|
||||
*
|
||||
</activemq.osgi.import.pkg>
|
||||
<activemq.osgi.export>
|
||||
org.apache.activemq.protocolbuffer*;version=${project.version},
|
||||
</activemq.osgi.export>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.activemq</groupId>
|
||||
<artifactId>activemq-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
<version>2.0.0beta</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
<plugins>
|
||||
<!-- Configure which tests are included/excuded -->
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<forkMode>pertest</forkMode>
|
||||
<childDelegation>false</childDelegation>
|
||||
<useFile>true</useFile>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,149 @@
|
|||
// See README.txt for information and build instructions.
|
||||
|
||||
package org.apache.activemq.protocolbuffer;
|
||||
|
||||
option optimize_for = SPEED;
|
||||
option java_package = "org.apache.activemq.protocolbuffer";
|
||||
|
||||
option java_outer_classname = "OpenWire";
|
||||
|
||||
|
||||
message Command {
|
||||
required int32 command_id = 1;
|
||||
required bool response_required = 2;
|
||||
required int32 command_type = 3;
|
||||
required bytes command_bytes = 4;
|
||||
}
|
||||
|
||||
|
||||
message Destination {
|
||||
enum DestinationType {
|
||||
QUEUE = 0;
|
||||
TOPIC = 1;
|
||||
TEMP_QUEUE = 2;
|
||||
TEMP_TOPIC = 3;
|
||||
}
|
||||
|
||||
required DestinationType type = 1 [default = QUEUE];
|
||||
required string name = 2;
|
||||
}
|
||||
|
||||
message LocalTransactionId {
|
||||
// TODO connection ID?
|
||||
required int32 connection_id = 1;
|
||||
required int64 value = 2;
|
||||
}
|
||||
|
||||
message XATransactionId {
|
||||
required int32 format_id = 1;
|
||||
required bytes branch_qualifier = 2;
|
||||
required bytes global_transaction_id = 3;
|
||||
}
|
||||
|
||||
// Properties
|
||||
message StringProperty {
|
||||
required string name = 1;
|
||||
required string value = 2;
|
||||
}
|
||||
|
||||
message BoolProperty {
|
||||
required string name = 1;
|
||||
required bool value = 2;
|
||||
}
|
||||
|
||||
message ByteProperty {
|
||||
required string name = 1;
|
||||
// TODO no byte?
|
||||
required int32 value = 2;
|
||||
}
|
||||
|
||||
message ShortProperty {
|
||||
required string name = 1;
|
||||
// TODO no int16?
|
||||
required int32 value = 2;
|
||||
}
|
||||
|
||||
message IntProperty {
|
||||
required string name = 1;
|
||||
required int32 value = 2;
|
||||
}
|
||||
|
||||
message LongProperty {
|
||||
required string name = 1;
|
||||
required int32 value = 2;
|
||||
}
|
||||
|
||||
message FloatProperty {
|
||||
required string name = 1;
|
||||
required float value = 2;
|
||||
}
|
||||
|
||||
message DoubleProperty {
|
||||
required string name = 1;
|
||||
required double value = 2;
|
||||
}
|
||||
|
||||
message Properties {
|
||||
repeated StringProperty string_property = 1;
|
||||
repeated IntProperty int_property = 2;
|
||||
repeated BoolProperty bool_property = 3;
|
||||
repeated LongProperty long_property = 4;
|
||||
repeated DoubleProperty double_property = 5;
|
||||
repeated FloatProperty float_property = 6;
|
||||
repeated ShortProperty short_property = 7;
|
||||
repeated ByteProperty byte_property = 8;
|
||||
}
|
||||
|
||||
// Message
|
||||
message Message {
|
||||
required int32 producer_id = 1;
|
||||
required int32 producer_counter = 2;
|
||||
|
||||
// TODO no messageID?
|
||||
|
||||
required Destination destination = 3;
|
||||
optional Destination original_destination = 4;
|
||||
|
||||
optional string group_id = 5;
|
||||
|
||||
optional bytes property_bytes = 6;
|
||||
|
||||
optional string correlation_id = 7;
|
||||
|
||||
// TODO move this into the 'exchange id'?
|
||||
optional bool persistent = 8;
|
||||
|
||||
optional int64 expiration = 9;
|
||||
|
||||
// TODO no byte?
|
||||
optional int32 priority = 10;
|
||||
optional Destination reply_to = 11;
|
||||
optional int64 timestamp = 12;
|
||||
optional string type = 13;
|
||||
|
||||
optional LocalTransactionId local_transaction_id = 14;
|
||||
optional XATransactionId xa_transaction_id = 15;
|
||||
|
||||
|
||||
// TODO why DataStructure and Content?
|
||||
// TODO targetConsumerId?
|
||||
|
||||
optional bool compressed = 16;
|
||||
optional int32 redelivery_counter = 17;
|
||||
repeated string broker_path = 18;
|
||||
repeated string cluster_id = 19;
|
||||
|
||||
optional string user_id = 20;
|
||||
|
||||
optional int64 arrival = 22;
|
||||
optional int64 broker_in_time = 23;
|
||||
optional int64 broker_out_time = 24;
|
||||
|
||||
// TODO required?
|
||||
optional bool droppable = 28;
|
||||
optional bool receivedByDFBridge = 29;
|
||||
|
||||
optional int32 group_sequence = 40;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/**
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.protocolbuffer;
|
||||
|
||||
import com.google.protobuf.CodedInputStream;
|
||||
import com.google.protobuf.CodedOutputStream;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.1 $
|
||||
*/
|
||||
public class PerformanceTest extends TestCase {
|
||||
protected int messageCount = 10;
|
||||
protected String fileName = "target/messages.openwire";
|
||||
|
||||
|
||||
public void testPerformance() throws Exception {
|
||||
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(fileName));
|
||||
CodedOutputStream cout = CodedOutputStream.newInstance(out);
|
||||
OpenWire.Destination destination = OpenWire.Destination.newBuilder().setName("FOO.BAR").setType(OpenWire.Destination.DestinationType.QUEUE).build();
|
||||
|
||||
for (int i = 0; i < messageCount; i++) {
|
||||
OpenWire.Message message = OpenWire.Message.newBuilder()
|
||||
.setDestination(destination)
|
||||
.setPersistent(true)
|
||||
.setProducerId(1234)
|
||||
.setProducerCounter(i)
|
||||
.setType("type:" + i)
|
||||
.build();
|
||||
|
||||
System.out.println("Writing message: " + i + " = " + message);
|
||||
message.writeTo(cout);
|
||||
//cout.flush();
|
||||
}
|
||||
cout.flush();
|
||||
out.close();
|
||||
|
||||
// now lets try read them!
|
||||
BufferedInputStream in = new BufferedInputStream(new FileInputStream(fileName));
|
||||
CodedInputStream cin = CodedInputStream.newInstance(in);
|
||||
for (int i = 0; i < messageCount; i++) {
|
||||
OpenWire.Message message = OpenWire.Message.parseFrom(cin);
|
||||
// todo test its not null or something?
|
||||
|
||||
System.out.println("Reading message: " + i + " = " + message);
|
||||
|
||||
}
|
||||
in.close();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue