1 Reply Latest reply on Sep 20, 2011 2:24 PM by vlari

    Pooled Connection Factories and Remote HornetQ servers

    vlari

      Hi all,

       

      I am trying to post to a remote (standalone) HornetQ (2.2.7) server from an app running in AS 7.0.1 (standalone-preview).

       

      Here is the code:

       

      {code}

      @Resource(mappedName="java:/JmsXA")

          private QueueConnectionFactory qcf;

       

          public void send(String message) throws Exception  {

              QueueConnection queueCon = null;

              try  {

                  queueCon = this.qcf.createQueueConnection("guest","guest");

                   QueueSession queueSession = queueCon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

                  Queue queue = new HornetQQueue("magicQueue");

                  QueueSender sender = queueSession.createSender(queue);

                   Message msg = queueSession.createTextMessage(message);

                  sender.send(msg);

              } finally {

                  if (queueCon != null) {

                      queueCon.close();

                  }

              }

           }

       

      {code}

       

      This code works fine on Glassfish - therefore, I know that the HQ server is properly configured and that the HQ Resource Adapter works fine.

       

      My question is how should I wire the pooled connection factory in standalone-preview.xml?

       

       

      Here is what I've done:

       

      1) Create a Netty connector configured to talk to the remote HQ server:

       

      {code:xml}

       

      <connectors>

            [...]

                      <netty-connector name="netty-remote" socket-binding="messaging">

                           <!-- host/port of the remote HQ server -->

                          <param key="host" value="192.168.0.3"/>

                          <param key="port" value="8000"/>

                       </netty-connector>

           [...]

      </connectors>

      {code}

       

      2) inject it in a pooled connection factory:

       

      {code:xml}

      <pooled-connection-factory name="hornetq-ra">

                          <connectors>

                               <connector-ref connector-name="netty-remote"/>

                          </connectors>

                          <entries>

                              <entry name="java:/JmsXA"/>

                           </entries>

                          <transaction mode="xa"/>

         </pooled-connection-factory>

      {code}

       

       

       

      The problem is that the  connection the factory creates is the embedded HQ server  (localhost), not to the remote one (192.168.0.3).

      Obviously, specifying the port and host on <netty-connector> has no effect.

       

      So, I tried to use the socket bindings. I defined:

       

      {code:xml}

      <interface name="remoteHQ">

                   <inet-address value="192.168.0.3"/>

         </interface>

      <socket-binding-group name="standard-sockets" default-interface="public">

         [...]    

          <socket-binding name="messagingRemote" port="8000" interface="remoteHQ"/>

            [...]

           </socket-binding-group>

      {code}

       

       

      And I use this binding in to configure the netty connector:

       

      {code:xml}<netty-connector name="netty-remote" socket-binding="messagingRemote"/>{code}

       

       

      which produces this exception:

       

      {code}

      MSC00001: Failed to start service jboss.network.remoteHQ: org.jboss.msc.service.StartException in service jboss.network.remoteHQ: failed to resolve interface remoteHQ

           at org.jboss.as.server.services.net.NetworkInterfaceService.start(NetworkInterfaceService.java:96)

      {code}

       

       

       

      Suggestions would be greatly apreciated.

       

      Thanks,

       

      vlari.

       

        • 1. Re: Pooled Connection Factories and Remote HornetQ servers
          vlari

          I might have hit a bug here.

           

          The 'port' and 'host' parameters are being ignored in the following definition:

           

          {code:xml}
          <connectors>


                [...]


            <netty-connector name="netty-remote" socket-binding="messaging">


              <!-- host/port of the remote HQ server -->


              <param key="host" value="192.168.0.3"/>


              <param key="port" value="8000"/>


             </netty-connector>


               [...]



          </connectors>


          {code}

           

           

          When I insert a parameter with an invalid format:

           

           

          {code:xml}

          <connectors>


                [...]


            <netty-connector name="netty-remote" socket-binding="messaging">


              <!-- host/port of the remote HQ server -->


              <param key="host" value="192.168.0.3"/>


              <param key="boo" value="bar=foo"/>


              <param key="port" value="8000"/>


              </netty-connector>


               [...]


          </connectors>

          {code}

           

          I get the following exception:

           

           

          {code}

          Caused by: java.lang.IllegalArgumentException: Invalid expression boo=bar=foo at port=5445;boo=bar=foo;host=localhost

              at org.hornetq.ra.Util.parseConfig(Util.java:226)

              at org.hornetq.ra.HornetQResourceAdapter.setConnectionParameters(HornetQResourceAdapter.java:276)

          {code}

           

          It seems that org.jboss.as.connector.metadata.deployment.AbstractResourceAdapterDeploymentService$AbstractAS7RaDeployer.initAndInject  ignores the values I define for port and host.

           

          Could somebody please shed some light on this?

          At least I'd like to know if I'm barking up the wrong tree by trying to configure the netty connector in order to talk to a remote HQ server.

           

          Thanks -

           

          vlari