[Clev-jug] JMS Request/Reply problem

Shankar Mandal shankar.mandal at gmail.com
Mon Jun 19 15:51:40 CDT 2006


Hi,

I am using Request/REply mechanism using JMS.

My Reply is using the following code to send back the response to the
requesting program.

===============================================

  public void onMessage(Message msg)
  {
    try {
      String msgText;
      if (msg instanceof TextMessage) {
        msgText = ((TextMessage)msg).getText();
      } else {
        msgText = msg.toString();
      }
   int value = Integer.parseInt(msgText);
  Queue responseQ = (Queue)msg.getJMSReplyTo();
  System.out.println("Temporary Queue="+responseQ.getQueueName());
  responseSender = qsession.createSender(responseQ);

  Message response = qsession.createTextMessage(String.valueOf
(value*value));
  System.out.println("Received Message with ID:"+msg.getJMSMessageID() +"
and value:"+msgText);
  response.setJMSCorrelationID(msg.getJMSMessageID());

  responseSender.send(response);

      if (msgText.equalsIgnoreCase("quit")) {
        synchronized(this) {
          quit = true;
          this.notifyAll(); // Notify main thread to quit
        }
      }
    } catch (JMSException jmse) {
      jmse.printStackTrace();
    }
  }

============================================

But the request code is not able to get the response back. Can anyone look
in the aboce code and let me know if there is any problem.

Thanks,

Shankar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.urbancode.com/pipermail/clev-jug/attachments/20060619/4ee77fa9/attachment.htm


More information about the Clev-jug mailing list