Search in sources :

Example 6 with RMQTextMessage

use of com.rabbitmq.jms.client.message.RMQTextMessage in project rabbitmq-jms-client by rabbitmq.

the class RMQMessageProducerTest method preferMessagePropertyNoMessagePropertySpecified.

@Test
public void preferMessagePropertyNoMessagePropertySpecified() throws Exception {
    StubRMQMessageProducer producer = new StubRMQMessageProducer(session, destination, false);
    producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
    producer.setPriority(9);
    producer.setTimeToLive(1000L);
    RMQTextMessage message = new RMQTextMessage();
    producer.send(message);
    assertEquals(DeliveryMode.NON_PERSISTENT, message.getJMSDeliveryMode());
    assertEquals(9, message.getJMSPriority());
    assertTrue(message.getJMSExpiration() > System.currentTimeMillis());
}
Also used : RMQTextMessage(com.rabbitmq.jms.client.message.RMQTextMessage) Test(org.junit.jupiter.api.Test)

Example 7 with RMQTextMessage

use of com.rabbitmq.jms.client.message.RMQTextMessage in project rabbitmq-jms-client by rabbitmq.

the class SelectedTopicMessageIdentifierIT method testSendAndReceiveTextMessagesWithSelectorsAndPeriodIdentifiers.

@Test
public void testSendAndReceiveTextMessagesWithSelectorsAndPeriodIdentifiers() throws Exception {
    topicConn.start();
    TopicSession topicSession = topicConn.createTopicSession(false, Session.DUPS_OK_ACKNOWLEDGE);
    Topic topic = topicSession.createTopic(TOPIC_NAME);
    TopicPublisher sender = topicSession.createPublisher(topic);
    TopicSubscriber receiver1 = topicSession.createSubscriber(topic, "period.bool.prop", false);
    TopicSubscriber receiver2 = topicSession.createSubscriber(topic, "not period.bool.prop", false);
    sender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
    TextMessage message1 = topicSession.createTextMessage(MESSAGE1);
    TextMessage message2 = topicSession.createTextMessage(MESSAGE2);
    message1.setBooleanProperty("period.bool.prop", true);
    message2.setBooleanProperty("period.bool.prop", false);
    sender.send(message1);
    sender.send(message2);
    RMQTextMessage tmsg1 = (RMQTextMessage) receiver1.receive();
    RMQTextMessage tmsg2 = (RMQTextMessage) receiver2.receive();
    String t1 = tmsg1.getText();
    String t2 = tmsg2.getText();
    assertEquals(MESSAGE1, t1);
    assertEquals(MESSAGE2, t2);
}
Also used : TopicSubscriber(javax.jms.TopicSubscriber) TopicSession(javax.jms.TopicSession) TopicPublisher(javax.jms.TopicPublisher) RMQTextMessage(com.rabbitmq.jms.client.message.RMQTextMessage) Topic(javax.jms.Topic) TextMessage(javax.jms.TextMessage) RMQTextMessage(com.rabbitmq.jms.client.message.RMQTextMessage) Test(org.junit.jupiter.api.Test)

Aggregations

RMQTextMessage (com.rabbitmq.jms.client.message.RMQTextMessage)7 Test (org.junit.jupiter.api.Test)6 TextMessage (javax.jms.TextMessage)2 Topic (javax.jms.Topic)2 TopicPublisher (javax.jms.TopicPublisher)2 TopicSession (javax.jms.TopicSession)2 TopicSubscriber (javax.jms.TopicSubscriber)2 AMQP (com.rabbitmq.client.AMQP)1 RMQBytesMessage (com.rabbitmq.jms.client.message.RMQBytesMessage)1 RMQJMSException (com.rabbitmq.jms.util.RMQJMSException)1 IOException (java.io.IOException)1