Java Code Examples for javax.jms.JMSContext#createTopic()
The following examples show how to use
javax.jms.JMSContext#createTopic() .
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: JMSContextIntegrationTest.java From qpid-jms with Apache License 2.0 | 6 votes |
@Test(timeout = 20000) public void testCreateContextWithTransactedSessionMode() throws Exception { Binary txnId = new Binary(new byte[]{ (byte) 5, (byte) 6, (byte) 7, (byte) 8}); try (TestAmqpPeer testPeer = new TestAmqpPeer();) { JMSContext context = testFixture.createJMSContext(testPeer, JMSContext.SESSION_TRANSACTED); assertEquals(JMSContext.SESSION_TRANSACTED, context.getSessionMode()); // Session should be created and a coordinator should be attached since this // should be a TX session, then a new TX is declared, once closed the TX should // be discharged as a roll back. testPeer.expectBegin(); testPeer.expectCoordinatorAttach(); testPeer.expectDeclare(txnId); testPeer.expectDischarge(txnId, true); testPeer.expectEnd(); testPeer.expectClose(); context.createTopic("TopicName"); context.close(); testPeer.waitForAllHandlersToComplete(1000); } }
Example 2
Source File: JmsSource.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
private Destination getDestination(JMSContext context, String name, JmsConnectorIncomingConfiguration config) { String type = config.getDestinationType(); switch (type.toLowerCase()) { case "queue": log.creatingQueue(name); return context.createQueue(name); case "topic": log.creatingTopic(name); return context.createTopic(name); default: throw ex.illegalArgumentUnknownDestinationType(type); } }
Example 3
Source File: JmsSink.java From smallrye-reactive-messaging with Apache License 2.0 | 5 votes |
private Destination getDestination(JMSContext context, String name, String type) { switch (type.toLowerCase()) { case "queue": return context.createQueue(name); case "topic": return context.createTopic(name); default: throw ex.illegalStateUnknownDestinationType(type); } }
Example 4
Source File: JmsPoolJMSContextTest.java From pooled-jms with Apache License 2.0 | 5 votes |
@Test(timeout = 30000) public void testCreateTopic() { JMSContext context = cf.createContext(); assertNotNull(context.createTopic(getTestName())); context.close(); try { context.createTopic(getTestName()); fail("Should not be able to create resource when context is closed"); } catch (IllegalStateRuntimeException isre) {} }
Example 5
Source File: JmsPoolJMSContextTest.java From pooled-jms with Apache License 2.0 | 5 votes |
@Test(timeout = 30000) public void testSharedCreateConsumer() { JMSContext context = cf.createContext(); Topic topic = context.createTopic(getTestName()); assertNotNull(context.createSharedConsumer(topic, "name")); context.close(); try { context.createSharedConsumer(topic, "name"); fail("Should not be able to create resource when context is closed"); } catch (IllegalStateRuntimeException isre) {} }
Example 6
Source File: JmsPoolJMSContextTest.java From pooled-jms with Apache License 2.0 | 5 votes |
@Test(timeout = 30000) public void testSharedCreateConsumerWithSelector() { JMSContext context = cf.createContext(); Topic topic = context.createTopic(getTestName()); assertNotNull(context.createSharedConsumer(topic, "name", "color = yellow")); context.close(); try { context.createSharedConsumer(topic, "name", "color = green"); fail("Should not be able to create resource when context is closed"); } catch (IllegalStateRuntimeException isre) {} }
Example 7
Source File: JmsPoolJMSContextTest.java From pooled-jms with Apache License 2.0 | 5 votes |
@Test(timeout = 30000) public void testCreateDurableConsumer() { JMSContext context = cf.createContext(); Topic topic = context.createTopic(getTestName()); assertNotNull(context.createDurableConsumer(topic, "test")); context.close(); try { context.createDurableConsumer(topic, "test"); fail("Should not be able to create resource when context is closed"); } catch (IllegalStateRuntimeException isre) {} }
Example 8
Source File: JmsPoolJMSContextTest.java From pooled-jms with Apache License 2.0 | 5 votes |
@Test(timeout = 30000) public void testCreateSharedDurableConsumer() { JMSContext context = cf.createContext(); Topic topic = context.createTopic(getTestName()); assertNotNull(context.createSharedDurableConsumer(topic, "test")); context.close(); try { context.createSharedDurableConsumer(topic, "test"); fail("Should not be able to create resource when context is closed"); } catch (IllegalStateRuntimeException isre) {} }
Example 9
Source File: JmsPoolJMSContextTest.java From pooled-jms with Apache License 2.0 | 5 votes |
@Test(timeout = 30000) public void testCreateDurableConsumerWithSelector() { JMSContext context = cf.createContext(); Topic topic = context.createTopic(getTestName()); assertNotNull(context.createDurableConsumer(topic, "test", "color = red", true)); context.close(); try { context.createDurableConsumer(topic, "test", "color = red", true); fail("Should not be able to create resource when context is closed"); } catch (IllegalStateRuntimeException isre) {} }
Example 10
Source File: JmsPoolJMSContextTest.java From pooled-jms with Apache License 2.0 | 5 votes |
@Test(timeout = 30000) public void testCreateSharedDurableConsumerWithSelector() { JMSContext context = cf.createContext(); Topic topic = context.createTopic(getTestName()); assertNotNull(context.createSharedDurableConsumer(topic, "test", "color = red")); context.close(); try { context.createSharedDurableConsumer(topic, "test", "color = red"); fail("Should not be able to create resource when context is closed"); } catch (IllegalStateRuntimeException isre) {} }
Example 11
Source File: JNDI.java From perf-harness with MIT License | 5 votes |
/** * <b>JMS 2.0</b> * @param uri String containing topic name * @param context Active JMSContext must be supplied if not retrieving from JNDI * @return A valid DestinationWrapper object containing a queue retrieved from JNDI or created from the provided JMSContext * @throws NamingException */ public DestinationWrapper<Topic> lookupTopic(String uri, JMSContext context) throws JMSException, NamingException { if (usingJNDI || context == null) { return lookupTopicFromJNDI(uri); } else { return new DestinationWrapper<Topic>(uri, context.createTopic(uri)); } }
Example 12
Source File: JMSSessionFactory.java From apicurio-studio with Apache License 2.0 | 5 votes |
/** * Called to add a consumer to the JMS topic specific to the given design id. * @param designId * @param handler */ public synchronized MessagingSessionContainer joinSession(String designId, IOperationHandler handler) { logger.debug("Joining session {}", designId); JMSContext context = connectionFactory.createContext(); Topic sessionTopic = context.createTopic(JAVA_JMS_TOPIC_SESSION + designId); // Subscribe to the topic JMSConsumer consumer = context.createConsumer(sessionTopic, null, true); // When a new node joins the distributed session, it doesn't know about the session(s) attached to the // other nodes already in the session(s). return new MessagingSessionContainer(sessionTopic, consumer, context.createProducer(), handler); }
Example 13
Source File: JMSContextIntegrationTest.java From qpid-jms with Apache License 2.0 | 5 votes |
@Test(timeout = 20000) public void testCreateAutoAckSessionByDefault() throws Exception { try (TestAmqpPeer testPeer = new TestAmqpPeer();) { JMSContext context = testFixture.createJMSContext(testPeer); assertEquals(JMSContext.AUTO_ACKNOWLEDGE, context.getSessionMode()); testPeer.expectBegin(); context.createTopic("TopicName"); testPeer.expectEnd(); testPeer.expectClose(); context.close(); testPeer.waitForAllHandlersToComplete(1000); } }
Example 14
Source File: JMSContextIntegrationTest.java From qpid-jms with Apache License 2.0 | 5 votes |
@Test(timeout = 20000) public void testCreateContextFromContextWithSessionsActive() throws Exception { try (TestAmqpPeer testPeer = new TestAmqpPeer();) { JMSContext context = testFixture.createJMSContext(testPeer); assertEquals(JMSContext.AUTO_ACKNOWLEDGE, context.getSessionMode()); testPeer.expectBegin(); context.createTopic("TopicName"); // Create a second should not create a new session yet, once a new connection is // create on demand then close of the second context should only close the session JMSContext other = context.createContext(JMSContext.CLIENT_ACKNOWLEDGE); assertEquals(JMSContext.CLIENT_ACKNOWLEDGE, other.getSessionMode()); testPeer.expectBegin(); testPeer.expectEnd(); other.createTopic("TopicName"); other.close(); testPeer.waitForAllHandlersToComplete(1000); // Now the connection should close down. testPeer.expectEnd(); testPeer.expectClose(); context.close(); testPeer.waitForAllHandlersToComplete(1000); } }
Example 15
Source File: JMSProducerIntegrationTest.java From qpid-jms with Apache License 2.0 | 4 votes |
@Test(timeout = 20000) public void testCreateProducerAndSend() throws Exception { try (TestAmqpPeer testPeer = new TestAmqpPeer();) { JMSContext context = testFixture.createJMSContext(testPeer, SERVER_ANONYMOUS_RELAY); testPeer.expectBegin(); //Expect a link to the anonymous relay node TargetMatcher targetMatcher = new TargetMatcher(); targetMatcher.withAddress(nullValue()); targetMatcher.withDynamic(nullValue());//default = false targetMatcher.withDurable(nullValue());//default = none/0 testPeer.expectSenderAttach(targetMatcher, false, false); JMSProducer producer = context.createProducer(); assertNotNull(producer); String topicName = "testCreateProducerAndSend"; Topic topic = context.createTopic(topicName); // Verify sent message contains expected destination address and dest type annotation MessageAnnotationsSectionMatcher msgAnnotationsMatcher = new MessageAnnotationsSectionMatcher(true); Symbol annotationKey = AmqpDestinationHelper.JMS_DEST_TYPE_MSG_ANNOTATION_SYMBOL; msgAnnotationsMatcher.withEntry(annotationKey, equalTo(AmqpDestinationHelper.TOPIC_TYPE)); MessagePropertiesSectionMatcher propsMatcher = new MessagePropertiesSectionMatcher(true).withTo(equalTo(topicName)); TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher(); messageMatcher.setHeadersMatcher(new MessageHeaderSectionMatcher(true).withDurable(equalTo(true))); messageMatcher.setMessageAnnotationsMatcher(msgAnnotationsMatcher); messageMatcher.setPropertiesMatcher(propsMatcher); testPeer.expectTransfer(messageMatcher); Message message = context.createMessage(); producer.send(topic, message); testPeer.expectEnd(); testPeer.expectClose(); context.close(); testPeer.waitForAllHandlersToComplete(1000); } }