13 Replies Latest reply on Jan 18, 2013 5:07 AM by ataylor

    MaxSessionInt on MDBs in durable subscriptions

    clebert.suconic

      I'm starting here a discussion about: https://jira.jboss.org/jira/browse/HORNETQ-312

       

      I believe it is legal to have MaxSession > 1 on MDB for durable subscriptions, right? We don't want MDBs to become singletons on durable subscriptions.

       

       

      If a MDB is busy processing a message, another consumer can kick in and start processing the message in parallel.

       

       

      It happens that HornetQMessageHandler had a check on number of consumers which is inconsistent with hornetQActivation, since it will start multiple Handlers for a given subscription:

       

             for (int i = 0; i < spec.getMaxSessionInt(); i++)

            {

               ClientSession session = setupSession();

       

               HornetQMessageHandler handler = new HornetQMessageHandler(this, session);

               handler.setup();

               session.start();

               handlers.add(handler);

            }

      Hence, MDBs will always throw this following exception, unless you make maxSession = 1:
                  // Already exists
                  if (subResponse.getConsumerCount() > 0)
                  {
                     throw new javax.jms.IllegalStateException("Cannot create a subscriber on the durable subscription since it already has subscriber(s)");
                  }