3 Replies Latest reply on Jul 12, 2011 5:10 PM by Andy Taylor

    MDB-onMessage is not invoked with remote hornetQ cluster server

    Partha Sarathi Dash Newbie

      Hi,

       

      I'm using hornetq-2.2.5.Final as a standalone server and jboss-5.1.0.GA for my MDB.

       

      My JBOSS is connetced to hornetQ through JCA connecter mentioned in deploy\hornetq-ra.rar\META-INF\ra.xml

       

      My configuration property looks like below:

           <resourceadapter-class>org.hornetq.ra.HornetQResourceAdapter</resourceadapter-class>

            <config-property>

               <description>

                  The transport type. Multiple connectors can be configured by using a comma separated list,

               </description>

               <config-property-name>ConnectorClassName</config-property-name>

               <config-property-type>java.lang.String</config-property-type>

               <config-property-value>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</config-property-value>

            </config-property>

       

            <config-property>

               <description>The transport configuration. These values must be in the form of key=val;key=val;,

                  if multiple connectors are used then each set must be separated by a comma i.e. host=host1;port=5445,host=host2;port=5446.

                  Each set of params maps to the connector classname specified.

               </description>        

               <config-property-name>ConnectionParameters</config-property-name>

               <config-property-type>java.lang.String</config-property-type>

               <config-property-value>host=localhost;port=5446,host=localhost;port=5447</config-property-value>

            </config-property>

       

      My hornetQ connection factory is a netty connector which listens on 5446 as below:

       

       

          <clustered>true</clustered>  

         <paging-directory>${data.dir:../data}/paging</paging-directory>

         <bindings-directory>${data.dir:../data}/bindings</bindings-directory>  

         <journal-directory>${data.dir:../data}/journal</journal-directory>  

         <journal-min-files>10</journal-min-files>

          <failover-on-shutdown>false</failover-on-shutdown>

         <shared-store>true</shared-store>  

         <large-messages-directory>${data.dir:../data}/large-messages</large-messages-directory>

       

         <connectors>     

            <connector name="netty-connector">

               <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>

               <param key="host"  value="${hornetq.remoting.netty.host:localhost}"/>

               <param key="port"  value="${hornetq.remoting.netty.port:5446}"/>

            </connector>

       

      My MDB message listener looks like:

      @MessageDriven(name = "LogReader", activationConfig = {

          @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),

          @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/AUALoggerQueue"),

          @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")

      })

      @ResourceAdapter("hornetq-ra.rar")

      public class LogReader implements MessageListener {

       

          private static final Logger LOGGER = Logger.getLogger(LogReader.class);

          private static final LogDao LOG_DAO = new LogDao();

          private static int counter;

       

          public LogReader() {

              try {

                  LOG_DAO.openConnection();

              } catch (SQLException e) {

                  LOGGER.error(e);

              }

          }

       

          public void onMessage(Message message) {

              LOGGER.info(++counter + (" message(s) dequeued"));

              if (message instanceof TextMessage) {

                  try {

                      String textMessage = ((TextMessage) message).getText();

                      LOGGER.info("Text received: " + textMessage);

                      LOG_DAO.save(textMessage);

                  } catch (JMSException ex) {

                      LOGGER.error("", ex);

                  } catch (SQLException e) {

                      LOGGER.error("", e);

                  }

              }

          }

      }

       

      They all work fine when I'm using in non clustered environment, My MDB onMessage method gets invoked properly. But when I run the hornetQ as a cluster with failover supoort my producer is successfully writing to the queue but my MDB onMessage method is not getting called.

       

      Any idea what is going wrong?

       

      Atttached my ra.xml, hornetq-configuration.xml