JMS Question - Revised


General J2EE: JMS Question - Revised

  1. JMS Question - Revised (2 messages)

    Sorry, earlier posting was truncated, some how.

    We have a used a topic to post requests, that are sent to external application, by the Topic Subscriber. When we receive response back, we want to match the request to the response.

    The way we thought we could achieve this is, by appending a uniqueID to the request and receiving the same ID back in the response (the external application guarantees to send that ID back). At the time of receiving the response create a durable subscriber to the same Topic above, and based on the ID of the response, receive the corresponding request from the Topic, using the message selector.

    However, with what we have seen, message selector can only be supplied as constructor argument. And, message selector has to have some value. In our case, it ought to be some thing like ID = '12345'. But, we don't know '12345' until we have received a response back from external application on the fly.

    With out having the second subscriber; we probably will loose the requests form the Topic by the time we receive responses back from external application, as they are received by the first subscriber.

    Any suggestions/ ideas?

    Threaded Messages (2)

  2. JMS Question - Revised[ Go to top ]

    One common way of matching up a response with a sent message, is to have the message consumer return the MessageID in CorrelationId.
    Then the message producer can create a receiver with a massage selector to qualify the response.
    Something like this:

    String messageSelector = "JMSCorrelationID='" + messageSent.getJMSMessageID() + "'";
    QueueReceiver queueReceiver = queueSession.createReceiver( queue, messageSelector );
  3. JMS Question - Revised[ Go to top ]

    Here's an overview of how to implement request-response in JMS along with a link to some source code you can reuse...