3 Replies Latest reply on Jul 3, 2013 3:34 AM by t.gueldner

    MDB for clustered JMS topic doesn't deploy?

    t.gueldner

      Hi,

       

      I want to use a JMS topic to notify all nodes of a cluster about an event.

       

      My JBoss AS 7.1.3 has a clustered messaging module. Queues are working fine and are load balanced.

       

      My MDB for the topic has the following configuration:

      {code}

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

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

              @ActivationConfigProperty(propertyName = "destination", propertyValue = "jms/topic/testTopic"),

              @ActivationConfigProperty(propertyName = "reconnectAttempts", propertyValue = "-1"),  

              @ActivationConfigProperty(propertyName = "setupAttempts", propertyValue = "-1"),

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

      {code}

       

      Deploying this MDB to node1 works fine. Depoying this MDB to node 2 results in two messages:

      Node 1 removes a HornetQ-Cluster connection:

      {quote}2013-06-27 10:19:45,052 INFO  (Thread-65 (HornetQ-client-global-threads-2074138690)) Removing clusterName=...{quote}

      Node 2 is trying to connect to the jms topic:

       

      {quote}2013-06-27 12:06:49,496 INFO  [org.hornetq.ra.inflow.HornetQActivation] (default-threads - 2) Attempting to reconnect or g.hornetq.ra.inflow.HornetQActivationSpec(ra=org.hornetq.ra.HornetQResourceAdapter@2574e2b6 destination=jms/topic/testTopic

      destinationType=javax.jms.Topic ack=Auto-acknowledge durable=false clientID=null user=null maxSession=15)

      2013-06-27 12:06:52,471 INFO  [org.hornetq.ra.inflow.HornetQActivation] (default-threads - 2) awaiting topic/queue creation jms/topic/testTopic

      {quote}

       

       

      Another approach would be to configure the MDB as a durable subscriber adding this config parameters:

      {code}

      @ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue = "Durable"),

      @ActivationConfigProperty(propertyName = "clientId", propertyValue = "consumer")

      {code}

       

      This works fine for node 1. Node 2 will raise an error in reason of duplicate clientId. To avoid duplicate clientIds I have to modify the code of my MDB and can't deploy the same artefact on different nodes. This is strange and definitely not thw way I want.

       

      What is the best solution? Durable or non durable subscription doesn't matter.

        • 1. Re: MDB for clustered JMS topic doesn't deploy?
          mnovak

          Hi,

           

          I'm afraid that in this case there is no other option than to specify unique clientId and subscriptionName for each MDB. This is working fine for me.

           

          HornetQ resource adapter does not accept creating subscription to topic without specifying clientId. Taken from HornetQMessageHandler.java:        

                   if (clientID == null)

                   {

                      throw new InvalidClientIDException("Cannot create durable subscription for " + subscriptionName +

                                                         " - client ID has not been set");

                   }

           

          You can try to create jira with feature request for HornetQ project on https://issues.jboss.org/secure/Dashboard.jspa

           

          Mirek

          • 2. Re: MDB for clustered JMS topic doesn't deploy?
            sfcoy

            I think that your use of a JMS Topic to send notifications to a "node" is incorrect.

             

            Java EE and JMS have no notion of a "node". You can have an application that exists in a cluster (and therefore distributed across multiple nodes), but it is notionally a single application, and therefore a single JMS client. Your application can have multiple subscribers to a Topic, but it is undefined which particular node will handle the message (you're not supposed to care).

            • 3. Re: MDB for clustered JMS topic doesn't deploy?
              t.gueldner

              He Stephen,

               

              you're right. Thanks for this hint.

               

              By the while I've found a better solution for my purpose: using a JGroups channel for notifying all nodes in the cluster.

               

              Thanks to Piotr Nowicki: http://piotrnowicki.com/2013/02/using-jgroups-directly-from-jboss-as-7-component/

               

              Thomas