0 Replies Latest reply on May 5, 2008 9:11 AM by Lukasz Jarzyna

    JMS Topic and RouteBack

    Lukasz Jarzyna Newbie

      Hello,
      I have a problem with JMS Topic and getting back the response. My config files:

      jboss-esb.xml

      <?xml version = "1.0" encoding = "UTF-8"?>
      <jbossesb
       xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd"
       parameterReloadSecs="5">
      
       <!--
       - -> MyService1 -> - |- - - MyService4
       | |
       | |
       | |
       -> - "quickstart-topic" - - -> MyService2 -> - |- - - MyService5
       | |
       | |
       | |
       - -> MyService3 -> - |- - - MyService6
       -->
      
       <providers>
       <jms-provider name="JBossMQ" connection-factory="ConnectionFactory"
       jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
       jndi-URL="localhost">
       <jms-bus busid="abw-topic">
       <jms-message-filter dest-type="TOPIC" dest-name="topic/abw_jmstopic_topic" />
       </jms-bus>
       <jms-bus busid="abw-queue-s1">
       <jms-message-filter dest-type="QUEUE" dest-name="queue/abw_jmstopic_queue_s1" />
       </jms-bus>
       <jms-bus busid="abw-queue-s2">
       <jms-message-filter dest-type="QUEUE" dest-name="queue/abw_jmstopic_queue_s2" />
       </jms-bus>
       <jms-bus busid="abw-queue-s3">
       <jms-message-filter dest-type="QUEUE" dest-name="queue/abw_jmstopic_queue_s3" />
       </jms-bus>
       <jms-bus busid="abw-queue-response-gtw">
       <jms-message-filter dest-type="QUEUE" dest-name="queue/abw_jmstopic_queue_response_gtw"/>
       </jms-bus>
       <jms-bus busid="abw-queue-response-srv">
       <jms-message-filter dest-type="QUEUE" dest-name="queue/abw_jmstopic_queue_response_srv"/>
       </jms-bus>
       <jms-bus busid="abwEsbChannel">
       <jms-message-filter dest-type="QUEUE" dest-name="queue/abw_Request_esb" />
       </jms-bus>
       </jms-provider>
       </providers>
      
       <services>
       <service category="MyServiceCategory" name="xxService" description="xxService">
       <listeners>
       <jms-listener name="JMS-Gateway" busidref="abw-topic" is-gateway="true" />
       <jms-listener name="JMS-ESBListener" busidref="abw-queue-s1" />
       </listeners>
       <actions mep="OneWay">
       <action name="request-mapper"
       class="pl.edu.pk.mech.ljarzyna.abw.actions.xxRequestAction"
       process="option1">
       </action>
       <action name="soapui-client-action"
       class="org.jboss.soa.esb.actions.soap.SOAPClient">
       <property name="wsdl" value="http://127.0.0.1:8080/xx/xxImpl?wsdl" />
       <property name="operation" value="sayHello" />
       <property name="responseAsOgnlMap" value="true" />
       <property name="SOAPAction" value="sayHello"/>
       </action>
       <action name="response-mapper"
       class="pl.edu.pk.mech.ljarzyna.abw.actions.xxResponseAction">
       </action>
       <action name="routeBack" class="org.jboss.soa.esb.actions.routing.JMSRouter">
       <property name="jndiName" value="queue/abw_jmstopic_queue_response_gtw" />
       <property name="unwrap" value="true" />
       </action>
       </actions>
       </service>
      
      
       </services>
      
      </jbossesb>
      


      sendjms class

      package pl.edu.pk.mech.ljarzyna.abwportal.searchbroker;
      
      import java.util.HashMap;
      import java.util.Map;
      
      import javax.jms.Connection;
      import javax.jms.ConnectionFactory;
      import javax.jms.JMSException;
      import javax.jms.MessageConsumer;
      import javax.jms.MessageProducer;
      import javax.jms.ObjectMessage;
      import javax.jms.Queue;
      import javax.jms.Session;
      import javax.jms.Topic;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;
      
      import org.jboss.soa.esb.client.ServiceInvoker;
      import org.jboss.soa.esb.message.Message;
      import org.jboss.soa.esb.message.format.MessageFactory;
      import org.jboss.soa.esb.message.format.MessageType;
      
      public class SendJMSMessage {
      
      // QueueConnection conn;
      // QueueSession session;
       Topic que;
       Queue queue;
       Connection connection;
       Session session;
      
       public void setupConnection() throws JMSException, NamingException
       {
       InitialContext iniCtx = new InitialContext();
       Object tmp = iniCtx.lookup("ConnectionFactory");
       ConnectionFactory qcf = (ConnectionFactory) tmp;
       connection = qcf.createConnection();
       que = (Topic) iniCtx.lookup("topic/abw_jmstopic_topic");
       queue = (Queue) iniCtx.lookup("queue/abw_jmstopic_queue_response_gtw");
       session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
       connection.start();
       System.out.println("Connection Started");
       }
      
       public void stop() throws JMSException
       {
       connection.stop();
       session.close();
       connection.close();
       }
      
       public void sendAMessage(String msg) throws JMSException
       {
       MessageProducer publisher = session.createProducer(que);
       MessageConsumer subscriber = session.createConsumer(queue);
       ObjectMessage tm = session.createObjectMessage(msg);
       publisher.send(tm);
       ObjectMessage message = (ObjectMessage) subscriber.receive(5000);
       if ( message == null)
       System.out.println("null");
       System.out.println("a: " + ((Message)message.getObject()).getBody().get());
      
       }
      
      
      }
      


      I want to send a jms topic to 3 services and they will do something and after that they sould return a response which will be displayed on jsp. Right now i get null message and don't know why.
      Could anyone help me with this ?