1 24 package deadMQueue; 25 26 import org.objectweb.joram.client.jms.admin.*; 27 28 import javax.jms.*; 29 import javax.naming.*; 30 31 34 public class DMQClient 35 { 36 static Context ictx = null; 37 38 public static void main(String [] args) throws Exception 39 { 40 ictx = new InitialContext(); 41 Queue queue = (Queue) ictx.lookup("queue"); 42 Topic topic = (Topic) ictx.lookup("topic"); 43 ConnectionFactory cf = (ConnectionFactory) ictx.lookup("cnxFact"); 44 ictx.close(); 45 46 Connection cnx = cf.createConnection(); 47 Session prodSession = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE); 48 Session consSession = cnx.createSession(true, 0); 49 MessageProducer qProducer = prodSession.createProducer(queue); 50 MessageProducer tProducer = prodSession.createProducer(topic); 51 52 MessageConsumer qConsumer = consSession.createConsumer(queue); 53 MessageConsumer tConsumer = consSession.createConsumer(topic); 54 55 cnx.start(); 56 57 TextMessage msg = prodSession.createTextMessage(); 58 59 msg.setText("Expiry test"); 61 qProducer.send(msg, javax.jms.DeliveryMode.NON_PERSISTENT, 4, 1); 62 tProducer.send(msg, javax.jms.DeliveryMode.NON_PERSISTENT, 4, 1); 63 64 qConsumer.receiveNoWait(); 65 tConsumer.receiveNoWait(); 66 67 msg.setText("Undeliverability test"); 69 qProducer.send(msg); 70 tProducer.send(msg); 71 qConsumer.receive(); 72 tConsumer.receive(); 73 consSession.rollback(); 74 qConsumer.receive(); 75 tConsumer.receive(); 76 consSession.rollback(); 77 78 cnx.close(); 79 } 80 } 81 | Popular Tags |