5 Replies Latest reply on Sep 28, 2006 1:13 AM by jsb

    Limit number of concurrent MDBs and number of retries?

      Dear All,

      I am finding when I set up a Queue much like the example at...

      http://trailblazer.demo.jboss.com/EJB3Trail/serviceobjects/mdb/

      ...JBoss instantiates several (I'm guessing around 5) consumers that all hungrily grab whatever appears on the Queue in a concurrent fashion. Also, if any of the message processing fails, they retry several (I'm guessing around 10) times before assigning the message to the DLQ.

      My question is: how can I control this behaviour?

      My requirement is for a sequential, single-threaded point-to-point, so all I want is one consumer that processes each message just once. If the message fails to consume then so be it: as long as it reached the consumer I'm happy.

      I have tried setting the ActivationConfigProperties maxSessions to 1, DLQMaxResent to 1, and transacted to false, as listed at...

      http://wiki.jboss.org/wiki/Wiki.jsp?page=ConfigJMSMessageListener

      ...but they all seem to have little effect?

      You help is most appreciated,

      Richard.

        • 1. Re: Limit number of concurrent MDBs and number of retries?

          If it helps, this page...

          http://wiki.jboss.org/wiki/Wiki.jsp?page=ConfigJBossMDB

          ...seems to be exactly what I want, with its mention of MaxmimumSize and MaxTimesRedelivered, but how do I configure this in my EJB3 environment?

          • 2. Re: Limit number of concurrent MDBs and number of retries?
            peter_kaas

            We use:

            @MessageDriven(activationConfig = {
             @ActivationConfigProperty(
             propertyName = "destinationType",
             propertyValue = "javax.jms.Queue"
             ),
             @ActivationConfigProperty(
             propertyName = "destination",
             propertyValue = "queue/trigger/Stage1EventBatchQueue"
             ),
             @ActivationConfigProperty(
             propertyName = "minPoolSize",
             propertyValue = "1"
             ),
             @ActivationConfigProperty(
             propertyName = "maxPoolSize",
             propertyValue = "1"
             )
            })
            


            in our code. I think the minPoolSize and maxPoolSize are what you are looking for (that works for us).

            As for getting a message just once: just make sure your MDB doesn't throw any exceptions by catching Throwable at the top of your onMessage()?


            • 3. Re: Limit number of concurrent MDBs and number of retries?

              Peter,

              Fantastic! I will give that a try - it sounds like exactly what I need!

              With regards to catching Exceptions, that one is more tricky: I do catch Exceptions at the top level of my onMessage (and don't rethrow them), but the message still gets re-delivered.

              Looking at the stack trace of the Exception that I catch, there's a lot of references to jboss.aop in there, so I fear JBoss may be detecting the Exception and rolling back even though I am catching it.

              Is there a parameter to limit the number of retries?

              Regards,

              Richard.

              • 4. Re: Limit number of concurrent MDBs and number of retries?

                For those travelling this way themselves, I found that using...

                void onMessage( Message p_message )
                {
                 if ( p_message.getJMSRedelivered()) return;
                 ...
                


                ...is a (slightly yucky) way of avoiding the resends. Of course, an ActivationConfigProperty would be better...

                • 5. Re: Limit number of concurrent MDBs and number of retries?
                  jsb

                  Came across this old topic looking for the answer to the same question... The ActivationConfigProperty that works for me with EJB3rc8 is:

                  @ActivationConfigProperty(propertyName = "DLQMaxTimesRedelivered", propertyValue = "0")