try
{
conn = cf.createTopicConnection();
TopicSession sess = conn.createTopicSession(true, 0);
TopicPublisher pub = sess.createPublisher(topic);
TopicSubscriber cons = sess.createSubscriber(topic);
conn.start();
Message m = sess.createTextMessage("testing123");
pub.publish(m);
sess.commit();
TextMessage m2 = (TextMessage)cons.receive(3000);
assertNotNull(m2);
assertEquals("testing123", m2.getText());
sess.rollback();
m2 = (TextMessage)cons.receive(3000);
assertNotNull(m2);
assertEquals("testing123", m2.getText());
conn.close();
conn = cf.createTopicConnection();
conn.start();
//test 2
TopicSession newsess = conn.createTopicSession(true, 0);
TopicPublisher newpub = newsess.createPublisher(topic);
TopicSubscriber newcons = newsess.createSubscriber(topic);
Message m3 = newsess.createTextMessage("testing456");
newpub.publish(m3);
newsess.commit();
TextMessage m4 = (TextMessage)newcons.receive(3000);
assertNotNull(m4);
assertEquals("testing456", m4.getText());
newsess.commit();
newpub.publish(m3);
newsess.commit();
TextMessage m5 = (TextMessage)newcons.receive(3000);
assertNotNull(m5);
assertEquals("testing456", m5.getText());
newsess.rollback();
TextMessage m6 = (TextMessage)newcons.receive(3000);
assertNotNull(m6);
assertEquals("testing456", m6.getText());
newsess.commit();