0 Replies Latest reply on Jun 3, 2009 7:36 AM by fady

    Esb-unaware JMS client with JMSReplyTo and RequestResponse M

    fady

      Hello everyone,

      I am using JBoss ESB 4.5.GA.

      With the following configuration:

       <providers>
       <jms-provider name="JBossMessaging"
       connection-factory="ConnectionFactory" >
       <jms-bus busid="syncjmsGwChannel">
       <jms-message-filter
       dest-type="QUEUE" dest-name="queue/syncjms_Request_gw" />
       </jms-bus>
       </jms-provider>
       </providers>
      
       <services>
       <service name="syncjmsListener"
       category="SyncJmsESBServices"
       description="Synchronous service over JMS"
       invmScope="GLOBAL" >
       <listeners>
       <jms-listener name="JBM-Gateway"
       busidref="syncjmsGwChannel"
       is-gateway="true" />
       </listeners>
       <actions mep="RequestResponse">
       <action name="echoAction" class="org.jboss.soa.esb.actions.routing.EchoRouter" />
       </actions>
       </service>
       </services>
      
      


      And this client code:

       public void testSyncJms() {
       QueueConnection conn = null;
       QueueSession session = null;
       QueueSender jmsSender = null;
       QueueReceiver jmsReceiver = null;
      
       try {
       InitialContext iniCtx = new InitialContext();
       QueueConnectionFactory qcf = (QueueConnectionFactory) iniCtx.lookup("ConnectionFactory");
       Queue jmsRequestQueue = (Queue) iniCtx.lookup("queue/syncjms_Request_gw");
       Queue jmsResponseQueue = (Queue) iniCtx.lookup("queue/syncjms_Request_gw_reply");
      
       conn = qcf.createQueueConnection();
       session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
       conn.start();
      
       jmsSender = session.createSender(jmsRequestQueue);
       TextMessage jmsRequestMessage = session.createTextMessage("bong");
       String correlationID = "ID:" + UUID.randomUUID().toString();
       jmsRequestMessage.setJMSCorrelationID(correlationID);
       jmsRequestMessage.setJMSReplyTo(jmsResponseQueue);
       jmsSender.send(jmsRequestMessage);
      
       jmsReceiver = session.createReceiver(jmsResponseQueue,
       "JMSCorrelationID = '" + correlationID + "'");
       TextMessage jmsResponseMessage = (TextMessage) jmsReceiver.receive(10000L);
       assertTrue(jmsResponseMessage != null);
       assertEquals("bong", jmsResponseMessage.getText());
      
       } catch (Exception e) {
       e.printStackTrace();
       fail(e.toString());
       } finally {
       try {
       if (jmsSender != null) { jmsSender.close(); }
       if (jmsReceiver != null) { jmsReceiver.close(); }
       if (session != null) { session.close(); }
       if (conn != null) { conn.stop(); conn.close(); }
       } catch (Exception e) {
       e.printStackTrace();
       fail(e.toString());
       }
       }
       }
      


      The client never gets a reply (not even a wrapped one). This is surprising because the documentation and some posts on this Forum mention that JMSReplyTo+RequestResponse should work. Is this because of the inVM transport or something I am doing wrong?

      With this second configuration though:

       <providers>
       <jms-provider name="JBossMessaging"
       connection-factory="ConnectionFactory" >
       <jms-bus busid="syncjmsGwChannel">
       <jms-message-filter
       dest-type="QUEUE" dest-name="queue/syncjms_Request_gw" />
       </jms-bus>
       </jms-provider>
       </providers>
      
       <services>
       <service name="syncjmsListener"
       category="SyncJmsESBServices"
       description="Synchronous service over JMS"
       invmScope="GLOBAL" >
       <listeners>
       <jms-listener name="JBM-Gateway"
       busidref="syncjmsGwChannel"
       is-gateway="true" />
       </listeners>
       <actions mep="OneWay">
       <action name="echoAction" class="org.jboss.soa.esb.actions.routing.EchoRouter" />
       <action name="routeAction" class="org.jboss.soa.esb.actions.routing.JMSRouter" >
       <property name="jndiName" value="queue/syncjms_Request_gw_reply"/>
       <property name="unwrap" value="true"/>
       </action>
       </actions>
       </service>
       </services>
      


      The same client code gets the reply fine.

      The second configuration is more verbose and less accurate since I am actually doing a Request/Response exchange, not a OneWay. Furthermore, it ignores the JMSReplyTo specified by the client since the reply destination is hardcoded in the JMSRouter.

      Is there a better way to achieve the desired result (RequestResponse + JMSReplyTo)?

      Thanks very much.

      Fady