3 Replies Latest reply on Apr 14, 2008 3:35 AM by Johannes Hartmann

    Reply from asynchrnous JMS Call

    Johannes Hartmann Newbie

      Hi,

      I want to invoke a service using JMS, which works perfect. However, I also want to receive the response of the service, which doesn't work at all.
      First the config used for testing:

      <jbossesb
       xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd"
       parameterReloadSecs="5">
      
       <providers>
       <jms-provider name="JMS-Provider"
       connection-factory="ConnectionFactory"
       jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
       jndi-URL="localhost">
       <jms-bus busid="EchoJmsEsbChannel">
       <jms-message-filter dest-type="QUEUE"
       dest-name="queue/inet_esb_test_echojms" />
       </jms-bus>
       <jms-bus busid="EchoJmsEsbGateway">
       <jms-message-filter dest-type="QUEUE"
       dest-name="queue/inet_esb_test_echojms_gw" />
       </jms-bus>
       </jms-provider>
       </providers>
      
       <services>
       <service category="EchoJmsEsb" name="EchoForward" description="incredible long description">
       <listeners>
       <jms-listener name="JMS-ESBListener"
       busidref="EchoJmsEsbChannel" maxThreads="5"/>
       <jms-listener name="JMS-Gateway"
       is-gateway="true" busidref="EchoJmsEsbGateway" maxThreads="5"/>
       </listeners>
      
       <actions mep="RequestResponse">
       ...
       </actions>
       </service>
       </services>
      </jbossesb>
      


      Using this configuration, responses won't get send back to the caller, which is pretty logic, as the JMS-Gateway can only be used in one way (as far as I understand) and thus ReplyTo isn't set in the Messageheader. (At least ReplyTo is not set when getting to the first action in the pipeline)

      Is there an easy way for getting the reply back to the caller? I don't want to write something like an action at the end of the pipeline, which sends the reply to a JMS Queue or something like a "ReplyTo-Header-Enricher"-action if not absolutly nessecary.

      Thanks & Greetings
      Johannes

        • 1. Re: Reply from asynchrnous JMS Call
          Johannes Hartmann Newbie

          ah, sorry, forgot that there is a JMSRouter - solved the problem with it :)

          • 2. Re: Reply from asynchrnous JMS Call
            David Sun Newbie

            Would you please share more info on your solution? Thanks

            • 3. Re: Reply from asynchrnous JMS Call
              Johannes Hartmann Newbie

              I only added a action with JMSRouter to the action pipeline, which sends the answer from the previous actions to a given JMS-queue:

              <actions mep="OneWay">
               <action name="anyActions"
               class="org.jboss.soa.esb.actions.soap.SOAPClient">
               <property name="wsdl" value="http://somewhere/svc?wsdl" />
               <property name="SOAPAction" value="doSomething" />
               </action>
               <!-- some more actions if required -->
               <action name="routeBack"
               class="org.jboss.soa.esb.actions.routing.JMSRouter">
               <property name="jndiName" value="queue/inet_esb_test_echojms_soapclient_reply" />
               <property name="unwrap" value="true" />
               </action>
              </actions>
              


              Another possibility (without JMSRouter) is to set JMSReplyTo before sending the message to the bus:
              ObjectMessage msg = session.createObjectMessage(content);
              msg.setJMSReplyTo(jmsReplyDestination);
              ...
              

              The Property MEP has to be set to "RequestResponse" in this case. Additionally, the message you get back isn't unwrapped, thus not really understandable for a ESB-unaware receiver. So I prefer the first solution.

              Hope this helps

              Regards
              Johannes