1 Reply Latest reply on Nov 24, 2010 8:47 AM by tfennelly

    listener for ESBAware message+Socket communication

    sandeepgowda

      Hi,

          I am trying to use Jboss ESB as an interceptor for IP socket comunication.

      Usecase:

         Simple message, which used to get communicated through IP socket client & server program. But now i need to do the same communication through Jboss ESB queues.

       

      Configured the Jboss-esb.xml as below.

      1)Using the Jbr-provider

      2)Client code placed below(i am able to get the connection properly)

      3)Listener code is placed below.

       

      Queues are created properly,But listener java class is not getting invoked.(so that i get the message which has been transfered from client).

       

      console of jboss esb server 4.9 below

       

      15:29:38,519 INFO  [JBoss4ESBDeployer] create esb service, Socket.esb
      15:29:38,769 INFO  [QueueService] Queue[/queue/socket_in_q] started, fullSize=200000, pageSize=2000, downCacheSize=2000
      15:32:22,518 INFO  [JBossRemotingGatewayListener] JBoss Remoting Gateway listener 'listener' started.

       

       

      <?xml version="1.0"?>
      <jbossesb parameterReloadSecs="5"
          xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.2.0.xsd"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.2.0.xsd http://anonsvn.jboss.org/repos/labs/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.2.0.xsd">
          <providers>
              <jbr-provider host="localhost" name="JBR-Socket"
                  protocol="socket">
                  <jbr-bus busid="sockettest" port="6969" />
              </jbr-provider>
              <jms-provider connection-factory="ConnectionFactory"
                  name="socket-jms-provider">
                  <jms-bus busid="socketJmsProvider">
                      <jms-message-filter dest-name="queue/socket_in_q"
                          dest-type="QUEUE" />
                  </jms-bus>
              </jms-provider>
          </providers>
          <services>
              <service category="Socket" description="testSocket" name="socket-JMS-Service">
                  <listeners>
                      <jbr-listener busidref="sockettest" is-gateway="true"
                          name="socketGateway" />
                      <jms-listener busidref="socketJmsProvider" name="JMSEsbAware" />
                  </listeners>
                  <actions>
                      <action class="listener.SocketListener" name="socketlistener"
                          process="process" />
                  </actions>
              </service>
          </services>
      </jbossesb>

       

      Client Code:

           public class SendMessage {

       

          public static void main(String args[]) throws Throwable {
              SendMessage sm = new SendMessage();

       

              sm.sendMessageToJBRListener("http", 8080, "sandeep gowda");

       

          }

       

          private void sendMessageToJBRListener(String protocol, int port,
                  String message) throws Throwable {
              String locatorURI = protocol + "://localhost:" + port;
              InvokerLocator locator = new InvokerLocator(locatorURI);
              System.out
                      .println("Calling JBoss Remoting Listener using locator URI: "
                              + locatorURI);

       

              Client remotingClient = null;
              try {
                  remotingClient = new Client(locator);
                  remotingClient.connect();

       

                  // Deliver the message to the listener...
                  Object response = remotingClient.invoke(message);
                  System.out.println("JBR Class: " + response.getClass().getName());
                  System.out.println("Response from JBoss Remoting Listener '"
                          + locatorURI + "' was '" + response + "'.");
              } finally {
                  if (remotingClient != null) {
                      remotingClient.disconnect();
                  }
              }
          }
      }

       

      Listener code:

       

      public class SocketListener extends AbstractActionPipelineProcessor{
         
          protected ConfigTree _config;

       

          public SocketListener(ConfigTree config) {
              _config = config;
          }
         
          public Message process(Message arg0) throws ActionProcessingException {

       

              arg0.getContext();
             
              return arg0;
          }

       

      }

       

      Thanks

      Sandeep