6 Replies Latest reply on Aug 6, 2010 11:38 AM by Kevin Conner

    Request-response pattern using JMS?

    Mike Finn Newbie

      Maybe this has been discussed somewhere already but I can't find much on this topic.


      Looking to apply a request-response pattern over an ESB service (consumer is non-ESB), but using JMS, not HTTP/SOAP/etc. Specifically, we need to invoke an ESB service from a non-ESB-aware resource over JMS. No ESB message or ServiceInvoker available, just an inbound JMS message. The JMS provider could be WMQ, not just JBM.


      One of the ways this is typically solved (outside JBossESB, that is) is for the originator to set replyTo on the JMS request message and the provider to send response messages to that destination, setting corr id from msg id. That would seem impractical here, since it would imply there was an ESB-resolvable relationship from an arbitrary JMS destination on the incoming message to an EPR for the ESB message's replyTo by the gateway.


      The only other way we have come up with here is to use JMSRouter in the action pipeline to send responses to a fixed JMS queue. Just seems hammer and chisel, since we would probably have to manage the msgid/corrid in custom code, but maybe that's the way?


      Is there a generally accepted practice for doing this? Is it even supported without extra componentry to proxy between JMS and a ServiceInvoker call?


      Perhaps we are going about this all wrong? Any ideas or insight would be appreciated.




        • 1. Re: Request-response pattern using JMS?
          Nikos Massios Novice

          Hello Mike,


          It is nice to see that someone has the problem. We are doing it the same way (with a jms router so to speak - it is actually our own action).


          I tried making the ESB unware client setting the reply-to of the JMS message to the ESB JMS Gateway but I think the esb is ignoring it.



          • 2. Re: Request-response pattern using JMS?
            Hans Wolffenbuttel Expert



            Just had a look at the JmsGatewayListener and it sends it message asynchronous. This means that if you want request-response you need to build your own synchronous JmsGatewayListener. Putting a reply-to onto the message won't help since the serviceInvoker is using an asynchronous call.





            • 3. Re: Request-response pattern using JMS?
              Mike Finn Newbie



              Yes - I did notice that as well. Seems like a doable solution would be to build out a custom JmsGatewayListener to either take the response queue as config, or read queue name from jmsReplyTo, and ship the unwrapped response from deliverSync() to it. But, I was wondering if there were good reasons not to do something like that (ie ESB's "design center", other known/better implementations of EIPs like this, etc).


              I will have a go at this approach.




              • 4. Re: Request-response pattern using JMS?
                Nikos Massios Novice

                That sound nice.  How do you make jboss-esb.xml understand your new gateway listener?



                • 5. Re: Request-response pattern using JMS?
                  Mike Finn Newbie



                  That seems to be the challenge!


                  For now, I am just building a custom gateway listener and will plug it in via <listener>. The problem with this approach is that you can't link to <jms-bus>, only <bus>, so I will pass all the JMS config stuff in with KV config pairs. Good enough for a prototype.


                  Currently the JMS listener classname is hardcoded in JmsMapper, so the longer term options are to change org.jboss.soa.esb.listeners.gateway.JmsGatewayListener or add support in <*-listener> to support declaring a classname for the listener class. The latter IMO is the best solution but requires a bit more investment of time, and I'd like to see if that's practical over in dev forum.



                  • 6. Re: Request-response pattern using JMS?
                    Kevin Conner Master

                    The information should be stored in the ESB message and, assuming it reaches the far end, can be used from the JMS notifiers