use of org.apache.activemq.artemis.api.core.ICoreMessage in project activemq-artemis by apache.
the class TestConversions method testSimpleConversionBytes.
@Test
public void testSimpleConversionBytes() throws Exception {
Map<String, Object> mapprop = createPropertiesMap();
ApplicationProperties properties = new ApplicationProperties(mapprop);
MessageImpl message = (MessageImpl) Message.Factory.create();
message.setApplicationProperties(properties);
byte[] bodyBytes = new byte[4];
for (int i = 0; i < bodyBytes.length; i++) {
bodyBytes[i] = (byte) 0xff;
}
message.setBody(new Data(new Binary(bodyBytes)));
AMQPMessage encodedMessage = new AMQPMessage(message);
ICoreMessage serverMessage = encodedMessage.toCore();
ServerJMSBytesMessage bytesMessage = (ServerJMSBytesMessage) ServerJMSMessage.wrapCoreMessage(serverMessage);
verifyProperties(bytesMessage);
assertEquals(bodyBytes.length, bytesMessage.getBodyLength());
byte[] newBodyBytes = new byte[4];
bytesMessage.readBytes(newBodyBytes);
Assert.assertArrayEquals(bodyBytes, newBodyBytes);
}
use of org.apache.activemq.artemis.api.core.ICoreMessage in project activemq-artemis by apache.
the class JMSTransformationSpeedComparisonTest method testMessageWithNoPropertiesOrAnnotations.
@Test
public void testMessageWithNoPropertiesOrAnnotations() throws Exception {
Message message = Proton.message();
message.setAddress("queue://test-queue");
message.setDeliveryCount(1);
message.setCreationTime(System.currentTimeMillis());
message.setContentType("text/plain");
message.setBody(new AmqpValue("String payload for AMQP message conversion performance testing."));
AMQPMessage encoded = new AMQPMessage(message);
// Warm up
for (int i = 0; i < WARM_CYCLES; ++i) {
ICoreMessage intermediate = encoded.toCore();
encode(AMQPConverter.getInstance().fromCore(intermediate));
}
long totalDuration = 0;
long startTime = System.nanoTime();
for (int i = 0; i < PROFILE_CYCLES; ++i) {
ICoreMessage intermediate = encoded.toCore();
encode(AMQPConverter.getInstance().fromCore(intermediate));
}
totalDuration += System.nanoTime() - startTime;
LOG_RESULTS(totalDuration);
}
use of org.apache.activemq.artemis.api.core.ICoreMessage in project activemq-artemis by apache.
the class JMSTransformationSpeedComparisonTest method testTypicalQpidJMSMessage.
@Test
public void testTypicalQpidJMSMessage() throws Exception {
AMQPMessage encoded = new AMQPMessage(createTypicalQpidJMSMessage());
// Warm up
for (int i = 0; i < WARM_CYCLES; ++i) {
ICoreMessage intermediate = encoded.toCore();
encode(AMQPConverter.getInstance().fromCore(intermediate));
}
long totalDuration = 0;
long startTime = System.nanoTime();
for (int i = 0; i < PROFILE_CYCLES; ++i) {
ICoreMessage intermediate = encoded.toCore();
encode(AMQPConverter.getInstance().fromCore(intermediate));
}
totalDuration += System.nanoTime() - startTime;
LOG_RESULTS(totalDuration);
}
use of org.apache.activemq.artemis.api.core.ICoreMessage in project activemq-artemis by apache.
the class JMSTransformationSpeedComparisonTest method testTypicalQpidJMSMessageInBoundOnly.
@Test
public void testTypicalQpidJMSMessageInBoundOnly() throws Exception {
AMQPMessage encoded = encode(createTypicalQpidJMSMessage());
// Warm up
for (int i = 0; i < WARM_CYCLES; ++i) {
ICoreMessage intermediate = encoded.toCore();
encode(AMQPConverter.getInstance().fromCore(intermediate));
}
long totalDuration = 0;
long startTime = System.nanoTime();
for (int i = 0; i < PROFILE_CYCLES; ++i) {
ICoreMessage intermediate = encoded.toCore();
encode(AMQPConverter.getInstance().fromCore(intermediate));
}
totalDuration += System.nanoTime() - startTime;
LOG_RESULTS(totalDuration);
}
Aggregations