use of javax.jms.TopicPublisher 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);
}
use of javax.jms.TopicPublisher in project rabbitmq-jms-client by rabbitmq.
the class TemporaryTopicIT method testTopicSendAndReceiveTwoSessions.
@Test
public void testTopicSendAndReceiveTwoSessions() throws Exception {
topicConn.start();
TopicSession topicSession1 = topicConn.createTopicSession(false, Session.DUPS_OK_ACKNOWLEDGE);
TopicSession topicSession2 = topicConn.createTopicSession(false, Session.DUPS_OK_ACKNOWLEDGE);
Topic topic = topicSession1.createTemporaryTopic();
TopicPublisher topicSender = topicSession1.createPublisher(topic);
topicSender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
TopicSubscriber topicReceiver1 = topicSession1.createSubscriber(topic);
TopicSubscriber topicReceiver2 = topicSession2.createSubscriber(topic);
TextMessage message = topicSession1.createTextMessage(MESSAGE);
topicSender.send(message);
TextMessage message1 = (TextMessage) topicReceiver1.receive(1000);
TextMessage message2 = (TextMessage) topicReceiver2.receive(1000);
assertNotNull(message1);
assertNotNull(message2);
assertEquals(MESSAGE, message1.getText());
assertEquals(MESSAGE, message2.getText());
}
use of javax.jms.TopicPublisher in project rabbitmq-jms-client by rabbitmq.
the class TemporaryTopicIT method testTopicSendAndReceiveSingleSession.
@Test
public void testTopicSendAndReceiveSingleSession() throws Exception {
topicConn.start();
TopicSession topicSession = topicConn.createTopicSession(false, Session.DUPS_OK_ACKNOWLEDGE);
Topic topic = topicSession.createTemporaryTopic();
TopicPublisher topicSender = topicSession.createPublisher(topic);
topicSender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
TopicSubscriber topicReceiver1 = topicSession.createSubscriber(topic);
TopicSubscriber topicReceiver2 = topicSession.createSubscriber(topic);
TextMessage message = topicSession.createTextMessage(MESSAGE);
topicSender.send(message);
TextMessage message1 = (TextMessage) topicReceiver1.receive(1000);
TextMessage message2 = (TextMessage) topicReceiver2.receive(1000);
assertNotNull(message1);
assertNotNull(message2);
assertEquals(MESSAGE, message1.getText());
assertEquals(MESSAGE, message2.getText());
}
Aggregations