use of org.apache.activemq.artemis.jms.client.ActiveMQTemporaryTopic in project activemq-artemis by apache.
the class AutoCreateJmsDestinationTest method testTemporaryTopic.
@Test
public void testTemporaryTopic() throws Exception {
Connection connection = cf.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
// javax.jms.Topic topic = ActiveMQJMSClient.createTopic(QUEUE_NAME);
ActiveMQTemporaryTopic topic = (ActiveMQTemporaryTopic) session.createTemporaryTopic();
MessageConsumer consumer = session.createConsumer(topic);
MessageProducer producer = session.createProducer(topic);
producer.send(session.createTextMessage("msg"));
connection.start();
assertNotNull(consumer.receive(500));
SimpleString topicAddress = topic.getSimpleAddress();
consumer.close();
assertNotNull(server.locateQueue(topicAddress));
IntegrationTestLogger.LOGGER.info("Topic name: " + topicAddress);
topic.delete();
connection.close();
// assertNotNull(server.getManagementService().getResource("jms.topic.test"));
assertNull(server.locateQueue(topicAddress));
}
use of org.apache.activemq.artemis.jms.client.ActiveMQTemporaryTopic in project activemq-artemis by apache.
the class CloseDestroyedConnectionTest method testClosingTemporaryTopicDeletesQueue.
@Test
public void testClosingTemporaryTopicDeletesQueue() throws JMSException, ActiveMQException {
conn = cf.createConnection();
Assert.assertEquals(1, server.getRemotingService().getConnections().size());
session1 = (ActiveMQSession) conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
ActiveMQTemporaryTopic topic = (ActiveMQTemporaryTopic) session1.createTemporaryTopic();
String address = topic.getAddress();
session1.close();
conn.close();
conn2 = cf.createConnection();
session2 = (ActiveMQSession) conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
ClientSession cs = session2.getCoreSession();
try {
cs.createConsumer(address);
fail("the address from the TemporaryTopic still exists!");
} catch (ActiveMQException e) {
assertEquals("expecting 'queue does not exist'", ActiveMQExceptionType.QUEUE_DOES_NOT_EXIST, e.getType());
}
}
Aggregations