121122123124125126127128129130131
TopicPublisher pub = sess.createPublisher(topic); pub.setDeliveryMode(DeliveryMode.PERSISTENT); Message m = sess.createTextMessage("testing123"); pub.publish(m); sess.commit(); conn.close(); conn = cf.createTopicConnection(); conn.start();
158159160161162163164165166167168
TopicSubscriber sub = sess.createSubscriber(topic); pub.setDeliveryMode(DeliveryMode.PERSISTENT); Message m = sess.createTextMessage("testing123"); pub.publish(m); sess.commit(); //receive but rollback TextMessage m2 = (TextMessage)sub.receive(3000); assertNotNull(m2);
201202203204205206207208209210211
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());
226227228229230231232233234235236
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());
232233234235236237238239240241242
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);
235236237238239240241242243244245
assertEquals("testing456", m4.getText()); newsess.commit(); newpub.publish(m3); newsess.commit(); TextMessage m5 = (TextMessage)newcons.receive(3000); assertNotNull(m5); assertEquals("testing456", m5.getText());
247248249250251252253254255256257
TextMessage m6 = (TextMessage)newcons.receive(3000); assertNotNull(m6); assertEquals("testing456", m6.getText()); newsess.commit(); } finally { if (conn != null)
272273274275276277278279280281282
publisher.publish(message, persistence, 4, 0); //publisher.publish(topic, message, persistence, 4, 0); //getLog().debug(" Sent #"+i); if (transacted == TRANS_INDIVIDUAL) { session.commit(); } } if (transacted == TRANS_TOTAL) {
278279280281282283284285286287288
} } if (transacted == TRANS_TOTAL) { session.commit(); } long endTime = System.currentTimeMillis(); session.close();
314315316317318319320321322323324
public void onMessage(Message message) { try { if( transacted == TRANS_INDIVIDUAL ) session.commit(); i++; } catch (JMSException e) { getLog().error("Unable to commit", e);