Java Code Examples for javax.jms.TemporaryTopic#delete()
The following examples show how to use
javax.jms.TemporaryTopic#delete() .
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: TempDestLoadTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
public void testLoadTempAdvisoryTopics() throws Exception { for (int i = 0; i < MESSAGE_COUNT; i++) { TemporaryTopic tempTopic = session.createTemporaryTopic(); MessageConsumer consumer = session.createConsumer(tempTopic); MessageProducer producer = session.createProducer(tempTopic); consumer.close(); producer.close(); tempTopic.delete(); } AdvisoryBroker ab = (AdvisoryBroker) broker.getBroker().getAdaptor(AdvisoryBroker.class); assertTrue(ab.getAdvisoryDestinations().size() == 0); assertTrue(ab.getAdvisoryConsumers().size() == 0); assertTrue(ab.getAdvisoryProducers().size() == 0); RegionBroker rb = (RegionBroker) broker.getBroker().getAdaptor(RegionBroker.class); for (Destination dest : rb.getDestinationMap().values()) { LOG.debug("Destination: {}", dest); } // there should be at least 2 destinations - advisories - // 1 for the connection + 1 generic ones assertTrue("Should be at least 2 destinations", rb.getDestinationMap().size() > 2); }
Example 2
Source File: SessionIntegrationTest.java From qpid-jms with Apache License 2.0 | 6 votes |
@Test(timeout = 20000) public void testCreateAndDeleteTemporaryTopic() throws Exception { try (TestAmqpPeer testPeer = new TestAmqpPeer();) { Connection connection = testFixture.establishConnecton(testPeer); connection.start(); testPeer.expectBegin(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); String dynamicAddress = "myTempTopicAddress"; testPeer.expectTempTopicCreationAttach(dynamicAddress); TemporaryTopic tempTopic = session.createTemporaryTopic(); // Deleting the TemporaryTopic will be achieved by closing its creating link. testPeer.expectDetach(true, true, true); tempTopic.delete(); testPeer.expectClose(); connection.close(); testPeer.waitForAllHandlersToComplete(1000); } }
Example 3
Source File: JmsConnectionTest.java From qpid-jms with Apache License 2.0 | 6 votes |
@Test(timeout=30000) public void testDeleteOfTempTopicOnClosedConnection() throws JMSException, IOException { connection = new JmsConnection(connectionInfo, provider); connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); TemporaryTopic tempTopic = session.createTemporaryTopic(); assertNotNull(tempTopic); connection.close(); try { tempTopic.delete(); fail("Should have thrown an IllegalStateException"); } catch (IllegalStateException ex) { } }
Example 4
Source File: JmsSessionTest.java From qpid-jms with Apache License 2.0 | 6 votes |
@Test(timeout=30000) public void testDeleteTemporaryTopic() throws Exception { connection = createAmqpConnection(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Topic topic = session.createTemporaryTopic(); assertNotNull(topic); assertTrue(topic instanceof TemporaryTopic); final BrokerViewMBean broker = getProxyToBroker(); assertEquals(1, broker.getTemporaryTopics().length); TemporaryTopic tempTopic = (TemporaryTopic) topic; tempTopic.delete(); assertTrue("Temp Topic should be deleted.", Wait.waitFor(new Wait.Condition() { @Override public boolean isSatisfied() throws Exception { return broker.getTemporaryTopics().length == 0; } }, TimeUnit.SECONDS.toMillis(30), TimeUnit.MILLISECONDS.toMillis(50))); }
Example 5
Source File: JmsTemporaryTopicTest.java From qpid-jms with Apache License 2.0 | 6 votes |
@Test(timeout = 60000) public void testCantDeleteTemporaryTopicWithConsumers() throws Exception { connection = createAmqpConnection(); connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); TemporaryTopic tempTopic = session.createTemporaryTopic(); MessageConsumer consumer = session.createConsumer(tempTopic); try { tempTopic.delete(); fail("should not be able to delete temporary topic with active consumers"); } catch (IllegalStateException ide) { // expected } consumer.close(); // Now it should be allowed tempTopic.delete(); }
Example 6
Source File: AdvisoryOpenWireTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testTempTopicLeak() throws Exception { Connection connection = null; try { connection = factory.createConnection(); connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); TemporaryTopic temporaryTopic = session.createTemporaryTopic(); temporaryTopic.delete(); Object[] queueResources = server.getManagementService().getResources(QueueControl.class); for (Object queueResource : queueResources) { if (((QueueControl) queueResource).getAddress().equals("ActiveMQ.Advisory.TempTopic")) { QueueControl queueControl = (QueueControl) queueResource; Wait.waitFor(() -> queueControl.getMessageCount() == 0); assertNotNull("addressControl for temp advisory", queueControl); Wait.assertEquals(0, queueControl::getMessageCount); Wait.assertEquals(2, queueControl::getMessagesAdded); } } } finally { if (connection != null) { connection.close(); } } }
Example 7
Source File: JMSTemporaryDestinationTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test(timeout = 30000) public void testDeleteTemporaryTopic() throws Exception { Connection connection = createConnection(); try { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); final javax.jms.Topic topic = session.createTemporaryTopic(); assertNotNull(topic); assertTrue(topic instanceof TemporaryTopic); Queue queueView = getProxyToQueue(topic.getTopicName()); assertNotNull(queueView); TemporaryTopic tempTopic = (TemporaryTopic) topic; tempTopic.delete(); assertTrue("Temp Queue should be deleted.", Wait.waitFor(new Wait.Condition() { @Override public boolean isSatisfied() throws Exception { return getProxyToQueue(topic.getTopicName()) == null; } }, TimeUnit.SECONDS.toMillis(30), TimeUnit.MILLISECONDS.toMillis(50))); } finally { connection.close(); } }
Example 8
Source File: MemoryAllocationTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
protected void releaseDestination(Destination dest) throws JMSException { if (dest instanceof TemporaryTopic) { TemporaryTopic tt = (TemporaryTopic) dest; tt.delete(); } else if (dest instanceof TemporaryQueue) { TemporaryQueue tq = (TemporaryQueue) dest; tq.delete(); } }
Example 9
Source File: TemporaryDestinationTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testTemporaryTopicDeleteWithConsumer() throws Exception { Connection conn = null; try { conn = createConnection(); Session producerSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); Session consumerSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); TemporaryTopic tempTopic = producerSession.createTemporaryTopic(); MessageConsumer consumer = consumerSession.createConsumer(tempTopic); try { tempTopic.delete(); ProxyAssertSupport.fail("Should throw JMSException"); } catch (JMSException e) { // Should fail - you can't delete a temp topic if it has active consumers } consumer.close(); } finally { if (conn != null) { conn.close(); } } }
Example 10
Source File: SessionIntegrationTest.java From qpid-jms with Apache License 2.0 | 5 votes |
@Test(timeout = 20000) public void testDeleteTemporaryTopicTimesOut() throws Exception { try (TestAmqpPeer testPeer = new TestAmqpPeer();) { JmsConnection connection = (JmsConnection) testFixture.establishConnecton(testPeer); connection.setCloseTimeout(500); connection.start(); testPeer.expectBegin(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); String dynamicAddress = "myTempTopicAddress"; testPeer.expectTempTopicCreationAttach(dynamicAddress); TemporaryTopic tempTopic = session.createTemporaryTopic(); // Deleting the TemporaryTopic will be achieved by closing its creating link. testPeer.expectDetach(true, false, true); try { tempTopic.delete(); fail("Should have timed out waiting to delete."); } catch (JmsOperationTimedOutException jmsEx) { LOG.info("Caught expected exception: {}", jmsEx.getMessage()); } testPeer.expectClose(); connection.close(); testPeer.waitForAllHandlersToComplete(1000); } }
Example 11
Source File: SessionIntegrationTest.java From qpid-jms with Apache License 2.0 | 5 votes |
@Test(timeout = 20000) public void testSendToDeletedTemporaryTopicFails() throws Exception { try (TestAmqpPeer testPeer = new TestAmqpPeer();) { Connection connection = testFixture.establishConnecton(testPeer); connection.start(); testPeer.expectBegin(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); String dynamicAddress = "myTempTopicAddress"; testPeer.expectTempTopicCreationAttach(dynamicAddress); TemporaryTopic tempTopic = session.createTemporaryTopic(); testPeer.expectSenderAttach(); MessageProducer producer = session.createProducer(tempTopic); // Deleting the TemporaryTopic will be achieved by closing its creating link. testPeer.expectDetach(true, true, true); tempTopic.delete(); try { producer.send(session.createMessage()); fail("Should detect that the destination was deleted and fail"); } catch (JMSException ignored) { } testPeer.expectClose(); connection.close(); testPeer.waitForAllHandlersToComplete(1000); } }
Example 12
Source File: SessionIntegrationTest.java From qpid-jms with Apache License 2.0 | 5 votes |
@Test(timeout = 20000) public void testCannotDeleteTemporaryTopicInUse() throws Exception { try (TestAmqpPeer testPeer = new TestAmqpPeer();) { Connection connection = testFixture.establishConnecton(testPeer); connection.start(); testPeer.expectBegin(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); String dynamicAddress = "myTempTopicAddress"; testPeer.expectTempTopicCreationAttach(dynamicAddress); TemporaryTopic tempTopic = session.createTemporaryTopic(); testPeer.expectReceiverAttach(); testPeer.expectLinkFlow(); MessageConsumer consumer = session.createConsumer(tempTopic); try { tempTopic.delete(); fail("Should not be able to delete an in use temp destination"); } catch (JMSException ex) { } testPeer.expectDetach(true, true, true); consumer.close(); // Deleting the TemporaryQueue will be achieved by closing its creating link. testPeer.expectDetach(true, true, true); tempTopic.delete(); testPeer.expectClose(); connection.close(); testPeer.waitForAllHandlersToComplete(1000); } }
Example 13
Source File: TemporaryDestinationTest.java From activemq-artemis with Apache License 2.0 | 2 votes |
@Test public void testTemporaryTopicDeletedAfterSessionClosed() throws Exception { server.getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoCreateAddresses(false).setAutoCreateQueues(false)); Connection conn = null; try { conn = createConnection(); Session producerSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); Session consumerSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); // Make sure temporary topic cannot be used after it has been deleted TemporaryTopic tempTopic = producerSession.createTemporaryTopic(); MessageProducer producer = producerSession.createProducer(tempTopic); MessageConsumer consumer = consumerSession.createConsumer(tempTopic); conn.start(); final String messageText = "This is a message"; javax.jms.Message m = producerSession.createTextMessage(messageText); producer.send(m); TextMessage m2 = (TextMessage) consumer.receive(2000); assertNotNull(m2); assertEquals(messageText, m2.getText()); consumer.close(); consumerSession.close(); producer.close(); producerSession.close(); tempTopic.delete(); producerSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); try { producer = producerSession.createProducer(tempTopic); producer.send(m); fail(); } catch (JMSException e) { } } finally { if (conn != null) { conn.close(); } } }
Example 14
Source File: TemporaryDestinationTest.java From activemq-artemis with Apache License 2.0 | 2 votes |
@Test public void testTemp() throws Exception { Connection conn = null; try { conn = createConnection(); Session producerSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); Session consumerSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); TemporaryTopic tempTopic = producerSession.createTemporaryTopic(); MessageProducer producer = producerSession.createProducer(tempTopic); MessageConsumer consumer = consumerSession.createConsumer(tempTopic); conn.start(); final String messageText = "This is a message"; Message m = producerSession.createTextMessage(messageText); producer.send(m); TextMessage m2 = (TextMessage) consumer.receive(2000); ProxyAssertSupport.assertNotNull(m2); ProxyAssertSupport.assertEquals(messageText, m2.getText()); try { tempTopic.delete(); ProxyAssertSupport.fail(); } catch (javax.jms.IllegalStateException e) { // Can't delete temp dest if there are open consumers } consumer.close(); tempTopic.delete(); } finally { if (conn != null) { conn.close(); } } }