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

    Receive and send message in the MDB

    Shriram Rajagopal Newbie

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

      public void onMessage(Message inmessage)
      // 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.");
      message = (TextMessage)receiver.receive();
      System.out.println("The Input message is: "+message.getText());

      // 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();

      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.