4 Replies Latest reply on Jan 30, 2009 9:16 AM by ryanhos

    JMS Gateway and RequestResponse

    nl

      Hi,

      I have a client application talking to the ESB via JMS in a kind of request-response-manner: Client sends a request to a queue, the ESB is listening on. ESB is processing the message and sends the reply back to the client. The client also opens a (temporary) response queue and puts it into the reply-to-field of the jms-message so that the esb knows where to send the answer to.

      I configured a jms-gateway, which picks up the request from the client and throws an esb message onto the bus. The gateway seems to act like an inbound-gateway, since it does not translate the jms-reply-to-field to an epr, but stores it in properties of the esb-message. Therefore an RequestResponse MEP won't work. So I added sort of a JMSRouter to the end of the action processing pipeline, which routes the message (reponse) to the correct JMS-Queue.

      This works but is not very. I would rather expect the JMS Gateway do handle inbound and outbound messages and configure my pipeline RequestResponse-style. But I don't have a clue gettin it to work. Or am I missing something?

      Thanks for any advice,

      Niels

        • 1. Re: JMS Gateway and RequestResponse
          rmolin

          Hi Niels,

          This works out of the box if you configure a reply queue with same name as your inbound queue + "_reply"

          See Programmers Guide pg. 26 (4.4.GA) - look for 'Default ReplyTo'

          /Rune

          • 2. Re: JMS Gateway and RequestResponse
            nl

            Hi Rune,

            thank your for this hint, but in doing so i will run into the problem, that if multiple clients calling the same service concurrently and listening on one and the same reply-queue the answer might be send to the "wrong" client. Since I'm using channels instead of topics and they are defined for peer-to-peer purposes.

            Niels

            • 3. Re: JMS Gateway and RequestResponse

              I ran into this same problem of wanting to do request-response JMS, and decided to write my own Notifier target (extends org.jboss.soa.esb.notification.NotificationTarget).

              If you set the reply to in your JMS client to a temporary queue (using the javax.jms standard function [setJMSReplyTo]), the class I wrote extracts that out of the message, or it will use a default queue you specify in the configuration.

              Since this is a NotificationTarget, I wanted to know the success/failure of the processing pipeline, not a response from each action.

              Here is a sample xml configuration to give you an idea of what I wrote:

              <target class="....Notifier" defaultQueue="queue/default_reply_to" notificationType="<success/error>" includeMsgBody="true/false" extraMsgProps="<client specified properties>"> </target>
              
              


              Sample result of this notification:
              <error messageID="myMessageId"><theInputMsg>something about this message made processing fail</theInputMsg></error>


              • 4. Re: JMS Gateway and RequestResponse
                ryanhos

                I believe that the ESB handles the request/response correlation on the default reply queues using jms message selectors. I wish I had more time to dig up the code or fire up an example to verify, but I have only 4 hours to move some code into peer review this morning. :)