Java Code Examples for javax.jms.TopicSession#createTemporaryTopic()
The following examples show how to use
javax.jms.TopicSession#createTemporaryTopic() .
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: JmsPoolTopicSubscriberTest.java From pooled-jms with Apache License 2.0 | 6 votes |
@Test public void testGetTopic() throws JMSException { JmsPoolConnection connection = (JmsPoolConnection) cf.createTopicConnection(); TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); Topic topic = session.createTemporaryTopic(); TopicSubscriber subscriber = session.createSubscriber(topic); assertNotNull(subscriber.getTopic()); assertSame(topic, subscriber.getTopic()); subscriber.close(); try { subscriber.getTopic(); fail("Cannot read topic on closed subscriber"); } catch (IllegalStateException ise) {} }
Example 2
Source File: JmsPoolTopicSubscriberTest.java From pooled-jms with Apache License 2.0 | 6 votes |
@Test public void testGetNoLocal() throws JMSException { JmsPoolConnection connection = (JmsPoolConnection) cf.createTopicConnection(); TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); Topic topic = session.createTemporaryTopic(); TopicSubscriber subscriber = session.createDurableSubscriber(topic, "name", "color = red", true); assertTrue(subscriber.getNoLocal()); subscriber.close(); try { subscriber.getNoLocal(); fail("Cannot read state on closed subscriber"); } catch (IllegalStateException ise) {} }
Example 3
Source File: JmsPoolTopicSubscriberTest.java From pooled-jms with Apache License 2.0 | 6 votes |
@Test public void testGetTopicSubscriber() throws JMSException { JmsPoolConnection connection = (JmsPoolConnection) cf.createTopicConnection(); TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); Topic topic = session.createTemporaryTopic(); JmsPoolTopicSubscriber subscriber = (JmsPoolTopicSubscriber) session.createDurableSubscriber(topic, "name", "color = red", true); assertNotNull(subscriber.getTopicSubscriber()); assertTrue(subscriber.getTopicSubscriber() instanceof MockJMSTopicSubscriber); subscriber.close(); try { subscriber.getTopicSubscriber(); fail("Cannot read state on closed subscriber"); } catch (IllegalStateException ise) {} }
Example 4
Source File: JmsPoolTopicPublisherTest.java From pooled-jms with Apache License 2.0 | 6 votes |
@Test public void testGetTopic() throws JMSException { JmsPoolConnection connection = (JmsPoolConnection) cf.createTopicConnection(); TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); Topic topic = session.createTemporaryTopic(); TopicPublisher publisher = session.createPublisher(topic); assertNotNull(publisher.getTopic()); assertSame(topic, publisher.getTopic()); publisher.close(); try { publisher.getTopic(); fail("Cannot read topic on closed publisher"); } catch (IllegalStateException ise) {} }
Example 5
Source File: JmsPoolTopicPublisherTest.java From pooled-jms with Apache License 2.0 | 6 votes |
@Test public void testGetTopicPublisher() throws JMSException { JmsPoolConnection connection = (JmsPoolConnection) cf.createTopicConnection(); TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); Topic topic = session.createTemporaryTopic(); JmsPoolTopicPublisher publisher = (JmsPoolTopicPublisher) session.createPublisher(topic); assertNotNull(publisher.getTopicPublisher()); assertTrue(publisher.getTopicPublisher() instanceof MockJMSTopicPublisher); publisher.close(); try { publisher.getTopicPublisher(); fail("Cannot read state on closed publisher"); } catch (IllegalStateException ise) {} }
Example 6
Source File: JmsPoolTopicSubscriberTest.java From pooled-jms with Apache License 2.0 | 5 votes |
@Test public void testToString() throws JMSException { JmsPoolConnection connection = (JmsPoolConnection) cf.createTopicConnection(); TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); Topic topic = session.createTemporaryTopic(); TopicSubscriber subscriber = session.createSubscriber(topic); assertNotNull(subscriber.toString()); }
Example 7
Source File: JmsPoolTopicPublisherTest.java From pooled-jms with Apache License 2.0 | 5 votes |
@Test public void testToString() throws JMSException { JmsPoolConnection connection = (JmsPoolConnection) cf.createTopicConnection(); TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); Topic topic = session.createTemporaryTopic(); TopicPublisher publisher = session.createPublisher(topic); assertNotNull(publisher.toString()); }
Example 8
Source File: JmsPoolTopicPublisherTest.java From pooled-jms with Apache License 2.0 | 5 votes |
@Test public void testPublishToTopicFailsIfNotAnonymousPublisher() throws JMSException { JmsPoolConnection connection = (JmsPoolConnection) cf.createTopicConnection(); TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); Topic topic = session.createTemporaryTopic(); TopicPublisher publisher = session.createPublisher(topic); try { publisher.publish(session.createTemporaryTopic(), session.createTextMessage()); fail("Should not be able to send to alternate destination"); } catch (UnsupportedOperationException ex) {} }
Example 9
Source File: SimpleOpenWireTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testTempTopicDelete() throws Exception { connection.start(); TopicSession topicSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); TemporaryTopic tempTopic = topicSession.createTemporaryTopic(); ActiveMQConnection newConn = (ActiveMQConnection) factory.createConnection(); try { TopicSession newTopicSession = newConn.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); TopicPublisher publisher = newTopicSession.createPublisher(tempTopic); // need to wait here because the ActiveMQ client's temp destination map is updated asynchronously, not waiting can introduce a race assertTrue(Wait.waitFor(() -> newConn.activeTempDestinations.size() == 1, 2000, 100)); TextMessage msg = newTopicSession.createTextMessage("Test Message"); publisher.publish(msg); try { TopicSubscriber consumer = newTopicSession.createSubscriber(tempTopic); fail("should have gotten exception but got consumer: " + consumer); } catch (JMSException ex) { //correct } connection.close(); try { Message newMsg = newTopicSession.createMessage(); publisher.publish(newMsg); } catch (JMSException e) { //ok } } finally { newConn.close(); } }