130131132133134135136137138139140
conn.start(); TopicSession newsess = conn.createTopicSession(true, 0); TopicSubscriber newcons = newsess.createSubscriber(topic); Message m2 = (Message)newcons.receive(200); assertNull(m2); } finally { if (conn != null)
161162163164165166167168169170171
Message m = sess.createTextMessage("testing123"); pub.publish(m); sess.commit(); //receive but rollback TextMessage m2 = (TextMessage)sub.receive(3000); assertNotNull(m2); assertEquals("testing123", m2.getText()); sess.rollback();
175176177178179180181182183184185
conn.start(); TopicSession newsess = conn.createTopicSession(true, 0); TopicSubscriber newcons = newsess.createSubscriber(topic); Message m3 = (Message)newcons.receive(200); assertNull(m3); } finally { if (conn != null)
203204205206207208209210211212213
Message m = sess.createTextMessage("testing123"); pub.publish(m); sess.commit(); TextMessage m2 = (TextMessage)cons.receive(3000); assertNotNull(m2); assertEquals("testing123", m2.getText()); sess.rollback();
209210211212213214215216217218219
assertNotNull(m2); assertEquals("testing123", m2.getText()); sess.rollback(); m2 = (TextMessage)cons.receive(3000); assertNotNull(m2); assertEquals("testing123", m2.getText()); conn.close();
228229230231232233234235236237238
Message m3 = newsess.createTextMessage("testing456"); newpub.publish(m3); newsess.commit(); TextMessage m4 = (TextMessage)newcons.receive(3000); assertNotNull(m4); assertEquals("testing456", m4.getText()); newsess.commit();
237238239240241242243244245246247
newsess.commit(); newpub.publish(m3); newsess.commit(); TextMessage m5 = (TextMessage)newcons.receive(3000); assertNotNull(m5); assertEquals("testing456", m5.getText()); newsess.rollback();
243244245246247248249250251252253
assertNotNull(m5); assertEquals("testing456", m5.getText()); newsess.rollback(); TextMessage m6 = (TextMessage)newcons.receive(3000); assertNotNull(m6); assertEquals("testing456", m6.getText()); newsess.commit();
157158159160161162163164165166167
} assertEquals(NUM_MESSAGES, count); log.debug("all messages received by sub1"); Message m = sub2.receive(200); assertNull(m); conn2.start();
166167168169170171172173174175176
conn2.start(); count = 0; while (true) { TextMessage tm = (TextMessage)sub2.receive(200); if (tm == null) { break; } assertEquals("hello", tm.getText());