1 Reply Latest reply on Jan 16, 2003 9:21 AM by Mauricio De Diana

    Reply error in simple MDB

    Mauricio De Diana Newbie

      Hi all,

      I´m new to JMS and JBossMQ and I´m developing a simple application to learn more about them.
      I have a simple MDB that receive a message from a queue and send it back to the client. Here is the code:

      MDB:

      TextMessage message = (TextMessage)msg;
      Queue queue = (Queue) msg.getJMSReplyTo();
      QueueSender sender = session.createSender(queue);
      TextMessage message2 = session.createTextMessage(message.getText());
      sender.send(message2);
      sender.close();

      Client:

      Context context = new InitialContext();
      QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory)context.lookup("ConnectionFactory");
      String queueName = "queue/mdbTestQueue";
      Queue queue = (Queue)context.lookup(queueName);
      QueueConnection queueConnection = queueConnectionFactory.createQueueConnection();
      QueueSession queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
      QueueSender queueSender = queueSession.createSender(queue);
      TextMessage message = queueSession.createTextMessage();

      final String messageString = "This is a TextMessage";
      message.setText(messageString);
      message.setJMSReplyTo(queue);

      queueSender.send(message);

      //--------------------------
      // Receiver code
      //--------------------------

      queueConnection.close();


      The problem is that it all works fine 80% of the time and fails the other 20%. And it fails because se getJMSReplyTo() call in MDB returns null. In this cases, the getText() method returns the expected message (i.e., the only information that get lost is JMSReplyTo, the rest is intact).

      Can anyone shed some light on this?

      Thanks,

      Dediana