mirror of https://github.com/apache/activemq.git
Add additional test for larger more complex AMQP message
(cherry picked from commit 5702ec8d7c
)
This commit is contained in:
parent
14c553a8ad
commit
95faf0d87c
|
@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -195,6 +196,34 @@ public class JMSTransformationSpeedComparisonTest {
|
||||||
transformer, PROFILE_CYCLES, TimeUnit.NANOSECONDS.toMillis(totalDuration), test.getMethodName());
|
transformer, PROFILE_CYCLES, TimeUnit.NANOSECONDS.toMillis(totalDuration), test.getMethodName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testComplexQpidJMSMessage() throws Exception {
|
||||||
|
|
||||||
|
EncodedMessage encoded = encode(createComplexQpidJMSMessage());
|
||||||
|
InboundTransformer inboundTransformer = getInboundTransformer();
|
||||||
|
OutboundTransformer outboundTransformer = getOutboundTransformer();
|
||||||
|
|
||||||
|
// Warm up
|
||||||
|
for (int i = 0; i < WARM_CYCLES; ++i) {
|
||||||
|
ActiveMQMessage intermediate = (ActiveMQMessage) inboundTransformer.transform(encoded);
|
||||||
|
intermediate.onSend();
|
||||||
|
outboundTransformer.transform(intermediate);
|
||||||
|
}
|
||||||
|
|
||||||
|
long totalDuration = 0;
|
||||||
|
|
||||||
|
long startTime = System.nanoTime();
|
||||||
|
for (int i = 0; i < PROFILE_CYCLES; ++i) {
|
||||||
|
ActiveMQMessage intermediate = (ActiveMQMessage) inboundTransformer.transform(encoded);
|
||||||
|
intermediate.onSend();
|
||||||
|
outboundTransformer.transform(intermediate);
|
||||||
|
}
|
||||||
|
totalDuration += System.nanoTime() - startTime;
|
||||||
|
|
||||||
|
LOG.info("[{}] Total time for {} cycles of transforms = {} ms -> [{}]",
|
||||||
|
transformer, PROFILE_CYCLES, TimeUnit.NANOSECONDS.toMillis(totalDuration), test.getMethodName());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTypicalQpidJMSMessageInBoundOnly() throws Exception {
|
public void testTypicalQpidJMSMessageInBoundOnly() throws Exception {
|
||||||
|
|
||||||
|
@ -314,6 +343,50 @@ public class JMSTransformationSpeedComparisonTest {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Message createComplexQpidJMSMessage() {
|
||||||
|
Map<String, Object> applicationProperties = new HashMap<String, Object>();
|
||||||
|
Map<Symbol, Object> messageAnnotations = new HashMap<Symbol, Object>();
|
||||||
|
|
||||||
|
applicationProperties.put("property-1", "string-1");
|
||||||
|
applicationProperties.put("property-2", 512);
|
||||||
|
applicationProperties.put("property-3", true);
|
||||||
|
applicationProperties.put("property-4", "string-2");
|
||||||
|
applicationProperties.put("property-5", 512);
|
||||||
|
applicationProperties.put("property-6", true);
|
||||||
|
applicationProperties.put("property-7", "string-3");
|
||||||
|
applicationProperties.put("property-8", 512);
|
||||||
|
applicationProperties.put("property-9", true);
|
||||||
|
|
||||||
|
messageAnnotations.put(Symbol.valueOf("x-opt-jms-msg-type"), 0);
|
||||||
|
messageAnnotations.put(Symbol.valueOf("x-opt-jms-dest"), 0);
|
||||||
|
|
||||||
|
Message message = Proton.message();
|
||||||
|
|
||||||
|
// Header Values
|
||||||
|
message.setPriority((short) 9);
|
||||||
|
message.setDurable(true);
|
||||||
|
message.setDeliveryCount(2);
|
||||||
|
message.setTtl(5000);
|
||||||
|
|
||||||
|
// Properties
|
||||||
|
message.setMessageId("ID:SomeQualifier:0:0:1");
|
||||||
|
message.setGroupId("Group-ID-1");
|
||||||
|
message.setGroupSequence(15);
|
||||||
|
message.setAddress("queue://test-queue");
|
||||||
|
message.setReplyTo("queue://reply-queue");
|
||||||
|
message.setCreationTime(System.currentTimeMillis());
|
||||||
|
message.setContentType("text/plain");
|
||||||
|
message.setCorrelationId("ID:SomeQualifier:0:7:9");
|
||||||
|
message.setUserId("username".getBytes(StandardCharsets.UTF_8));
|
||||||
|
|
||||||
|
// Application Properties / Message Annotations / Body
|
||||||
|
message.setApplicationProperties(new ApplicationProperties(applicationProperties));
|
||||||
|
message.setMessageAnnotations(new MessageAnnotations(messageAnnotations));
|
||||||
|
message.setBody(new AmqpValue("String payload for AMQP message conversion performance testing."));
|
||||||
|
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
private EncodedMessage encode(Message message) {
|
private EncodedMessage encode(Message message) {
|
||||||
ProtonJMessage amqp = (ProtonJMessage) message;
|
ProtonJMessage amqp = (ProtonJMessage) message;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue