1 Reply Latest reply on Mar 1, 2003 4:24 AM by Adrian Brock

    The best way to process synchronous messages

    Phill Newbie

      I'm trying to decide what the best way to process messages synchronously is. I understand that I can set up a session bean that does timed synchronous processing on a Queue much the same way a ServerSocket works. I was hoping I'd be able to use MDB's and 'push' the messages instead of pull them.

      But for a given subscriber, I only want to dispatch one message at a time, and wait for the subscriber to finish processing that message until the next message is dispatched.

      Thoughts? - Let me know if I'm not being clear.

      -phill

        • 1. Re: The best way to process synchronous messages
          Adrian Brock Master

          // Send and wait for a reply
          QueueRequestor queueRequestor = new QueueRequestor(session, queue);
          TextMessage message = session.createTextMessage();
          message.setText("Whatever");
          TextMessage reply = (TextMessage) queueRequestor.request(message);

          // Send the reply
          Queue replyTo = (Queue) message.getJMSReplyTo();
          QueueSender replySender = session.createSender(replyTo);
          TextMessage reply = session.createTextMessage();
          reply.setText("Whatever");
          reply.setJMSCorrelationID(message.getJMSMessageID());
          replySender.send(reply);

          Regards,
          Adrian