0 Replies Latest reply on Apr 18, 2006 1:44 AM by srjg75

    Receive and send message in the MDB

    srjg75

      In a MDB, I received a message from Queue A and want to send that message to Queue B.

      public void onMessage(Message inmessage)
      {
      try
      {
      // Get the input message (Inquiry.xml) from Queue A

      ctx = new InitialContext();
      cf = (QueueConnectionFactory)ctx.lookup("ConnectionFactory");
      destination = (Queue)ctx.lookup("queue/A");
      connection = cf.createQueueConnection();
      session = connection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
      receiver = session.createReceiver(destination);
      System.out.println("Waiting For A Message.");
      connection.start();
      message = (TextMessage)receiver.receive();
      System.out.println("The Input message is: "+message.getText());
      connection.close();

      // Put transformed message into Queue B
      System.out.println("Start--- Put Transformed message into Queue B");
      queOutput = (javax.jms.Queue)ctx.lookup("queue/B");
      connectionOutput = cf.createQueueConnection();
      sessionOutput = connectionOutput.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
      senderOutput = sessionOutput.createSender(queOutput);
      messageOutput = sessionOutput.createTextMessage();

      messageOutput.setText(transformed_message);
      senderOutput.send(message.getText());
      connectionOutput.close();
      System.out.println("End--- Put Transformed message into Queue B");


      If I put the code for the sending the message to queue B, it does not work. It does not even get the message from Queue A. However i remove the send of the message to queue B, the listening part for queue A works.

      Do we have to mention anything specific in xml configuration files to refer to queue B?

      Thanks for your help.

      Regards
      Shriram