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

The following examples show how to use org.apache.qpid.proton.message.impl.MessageImpl#setDeliveryCount() . 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: JMSTransformationSpeedComparisonTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
private MessageImpl createTypicalQpidJMSMessage() {
   Map<String, Object> applicationProperties = new HashMap<>();
   Map<Symbol, Object> messageAnnotations = new HashMap<>();

   applicationProperties.put("property-1", "string");
   applicationProperties.put("property-2", 512);
   applicationProperties.put("property-3", 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();

   message.setAddress("queue://test-queue");
   message.setDeliveryCount(1);
   message.setApplicationProperties(new ApplicationProperties(applicationProperties));
   message.setMessageAnnotations(new MessageAnnotations(messageAnnotations));
   message.setCreationTime(System.currentTimeMillis());
   message.setContentType("text/plain");
   message.setBody(new AmqpValue("String payload for AMQP message conversion performance testing."));

   return message;
}
 
Example 2
Source File: AmqpCodecTest.java    From qpid-jms with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeliveryCountSetFromMessageWithNonDefaultValue() throws Exception {
    MessageImpl message = (MessageImpl) Message.Factory.create();
    message.setDeliveryCount(2);
    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());
    assertTrue(jmsMessage.getJMSRedelivered());

    assertEquals("Unexpected facade class type", AmqpJmsTextMessageFacade.class, jmsMessage.getFacade().getClass());
    AmqpJmsTextMessageFacade facade = (AmqpJmsTextMessageFacade) jmsMessage.getFacade();
    assertNotNull("Facade should not be null", facade);
    assertEquals(2, facade.getRedeliveryCount());
    assertEquals(2, facade.getAmqpHeader().getDeliveryCount());
    assertEquals(UnsignedInteger.valueOf(2), facade.getHeader().getDeliveryCount());
}
 
Example 3
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 4
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;
}