Java Code Examples for org.apache.qpid.proton.message.impl.MessageImpl#setDurable()

The following examples show how to use org.apache.qpid.proton.message.impl.MessageImpl#setDurable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MessageTransformationTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testHeaderButNoPropertiesEncodeDecode() throws Exception {
   MessageImpl incomingMessage = (MessageImpl) Proton.message();

   incomingMessage.setBody(new AmqpValue("String payload for AMQP message conversion performance testing."));
   incomingMessage.setDurable(true);

   ICoreMessage core = encodeAndCreateAMQPMessage(incomingMessage).toCore();
   AMQPMessage outboudMessage = AMQPConverter.getInstance().fromCore(core, null);

   assertNotNull(outboudMessage.getHeader());

   Section body = outboudMessage.getBody();
   assertNotNull(body);
   assertTrue(body instanceof AmqpValue);
   assertTrue(((AmqpValue) body).getValue() instanceof String);
}
 
Example 2
Source File: AmqpCodecTest.java    From qpid-jms with Apache License 2.0 6 votes vote down vote up
@Test
public void testPersistentSetFromMessageWithNonDefaultValue() throws Exception {
    MessageImpl message = (MessageImpl) Message.Factory.create();
    message.setDurable(true);
    message.setBody(new AmqpValue("test"));

    JmsMessage jmsMessage = AmqpCodec.decodeMessage(mockConsumer, encodeMessage(message)).asJmsMessage();
    assertNotNull("Message should not be null", jmsMessage);
    assertEquals("Unexpected message class type", JmsTextMessage.class, jmsMessage.getClass());
    assertEquals(DeliveryMode.PERSISTENT, jmsMessage.getJMSDeliveryMode());

    JmsMessageFacade facade = jmsMessage.getFacade();
    assertNotNull("Facade should not be null", facade);
    assertEquals("Unexpected facade class type", AmqpJmsTextMessageFacade.class, facade.getClass());
    assertTrue(facade.isPersistent());
}
 
Example 3
Source File: AMQPMessageTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testIsDurableFromMessageWithHeaderTaggedAsTrue() {
   MessageImpl protonMessage = (MessageImpl) Message.Factory.create();
   protonMessage.setHeader(new Header());
   protonMessage.setDurable(true);

   AMQPStandardMessage decoded = encodeAndDecodeMessage(protonMessage);
   assertTrue(decoded.isDurable());
}
 
Example 4
Source File: AMQPMessageTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testIsDurableFromMessageWithHeaderTaggedAsFalse() {
   MessageImpl protonMessage = (MessageImpl) Message.Factory.create();
   protonMessage.setHeader(new Header());
   protonMessage.setDurable(false);

   AMQPStandardMessage decoded = encodeAndDecodeMessage(protonMessage);
   assertFalse(decoded.isDurable());
}
 
Example 5
Source File: MessageTransformationTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test
public void testComplexQpidJMSMessageEncodeDecode() throws Exception {
   Map<String, Object> applicationProperties = new HashMap<>();
   Map<Symbol, Object> messageAnnotations = new HashMap<>();

   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);
   messageAnnotations.put(Symbol.valueOf("x-opt-jms-reply-to"), 0);
   messageAnnotations.put(Symbol.valueOf("x-opt-delivery-delay"), 2000);

   MessageImpl message = (MessageImpl) 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."));

   ICoreMessage core = encodeAndCreateAMQPMessage(message).toCore();
   AMQPMessage outboudMessage = AMQPConverter.getInstance().fromCore(core, null);

   assertEquals(10, outboudMessage.getApplicationProperties().getValue().size());
   assertEquals(4, outboudMessage.getMessageAnnotations().getValue().size());
}
 
Example 6
Source File: JMSTransformationSpeedComparisonTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
private MessageImpl createComplexQpidJMSMessage() {
   Map<String, Object> applicationProperties = new HashMap<>();
   Map<Symbol, Object> messageAnnotations = new HashMap<>();

   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);

   MessageImpl message = (MessageImpl) 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;
}