public void testTemporaryTopic() throws Exception
{
AMQConnection conn = (AMQConnection) getConnection("guest", "guest");
TopicSession session = conn.createTopicSession(true, Session.AUTO_ACKNOWLEDGE);
TemporaryTopic topic = session.createTemporaryTopic();
assertNotNull(topic);
TopicPublisher producer = session.createPublisher(topic);
MessageConsumer consumer = session.createConsumer(topic);
conn.start();
producer.send(session.createTextMessage("hello"));
session.commit();
TextMessage tm = (TextMessage) consumer.receive(2000);
assertNotNull(tm);
assertEquals("hello", tm.getText());
session.commit();
try
{
topic.delete();
fail("Expected JMSException : should not be able to delete while there are active consumers");
}
catch (JMSException je)
{
; //pass
}
consumer.close();
try
{
topic.delete();
}
catch (JMSException je)
{
fail("Unexpected Exception: " + je.getMessage());
}