JMS Request Reply Pattern, No Output -


testrequestresponse:

public static void main(string args[]) throws jmsexception {     tibjmsconnectionfactory connectionfactory = new tibjmsconnectionfactory(             "tcp://localhost:7222");     connection con = connectionfactory.createconnection("admin", "");     con.start();     session s = con.createsession();     system.out.println("successfully created jms connection , session!");     queue q1 = s.createqueue("train.ems.queue.test");     system.out.println(q1);     system.out.println("queue created!");     temporaryqueue tq = s.createtemporaryqueue();     messageproducer mp = s.createproducer(q1);     messageconsumer mc = s.createconsumer(tq);     textmessage tm = s.createtextmessage("hi abhishek!");     tm.setstringproperty("country", "in");     tm.setjmscorrelationid("sender");     tm.setjmsreplyto(tq);     mp.settimetolive(30000);     mp.setdeliverymode(deliverymode.non_persistent);     mp.setpriority(message.default_priority);     mp.send(tm);     message recv = mc.receive(60000);     if (recv != null) {         system.out.println(recv.getbody(string.class));     }     mp.close();     s.close();     con.close();  } 

testasyncreceivemessage:

public class testasyncreceivemessage implements messagelistener { session s; queue q1;  messageproducer mp;  public static void main(string ars[]) throws jmsexception {     testasyncreceivemessage obj = new testasyncreceivemessage();     obj.createsession();     obj.createqueue();     obj.msgconsumer();  }  private void msgconsumer() throws jmsexception {     // todo auto-generated method stub     messageconsumer mc = s.createconsumer(q1, "country='in'");     mc.setmessagelistener(new testasyncreceivemessage()); }  private void createqueue() throws jmsexception {     // todo auto-generated method stub     q1 = s.createqueue("train.ems.queue.test");     // t1=s.createtopic("train.ems.topic.test"); }  private void createsession() throws jmsexception {     // todo auto-generated method stub     tibjmsconnectionfactory connectionfactory = new tibjmsconnectionfactory(             "tcp://localhost:7222");     connection con = connectionfactory.createconnection("admin", "");     s = con.createsession();     system.out.println("successfully created jms connection , session!");  }  public void onmessage(message arg0) {      try {         system.out.println(arg0.getbody(string.class));         textmessage tm = s.createtextmessage("ack");         queue t = (queue) arg0.getjmsreplyto();         mp = s.createproducer(t);         mp.send(tm);     } catch (jmsexception e) {         // todo auto-generated catch block         e.printstacktrace();     }  } 

well first showed me nullpointerexception when creating textmessage in onmessage, changed , theres no more exception, theres no putput either. help! :)

you have not called connection.start() method after creating in testasyncreceivemessage code. application has call connection.start() inform messaging provider start delivering messages. otherwise messages not delivered consumer.

connection.start typically called after consumer created , message listeners attached consumer consumer ready receive messages.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -