1 Reply Latest reply on Apr 23, 2012 2:53 AM by Samuel Tannous

    EJBException: Failed to acquire the pool semaphore

    Samuel Tannous Newbie

      Hi Guys,

       

      I see that this problem's come up a few times in the past but our scenario is different so I'll raise it again. We're using ActiveMQ in JBoss 6 and are seeing intermittent errors dispatching messages which causes them to be lost (the JMX consolde shows that they've been dequeued but the listener never gets them).

       

      There's a good explanation of the "Failed to acquire the pool semaphore" error here: http://stackoverflow.com/questions/7015583/ejbexception-failed-to-acquire-the-pool-semaphore

       

      And it sounds simple enough except we're not using prefetch... so my question is, how can this error occur when messages are being polled instead of batched?

       

      Our embedded broker url is:

      vm://myBroker?create=false&jms.prefetchPolicy.all=0&jms.alwaysSyncSend=true

       

      The ejb3-interceptors-aop.xml MDB config is default (@org.jboss.ejb3.annotation.Pool (value="StrictMaxPool", maxSize=15, timeout=10000))

       

      The message listener is annotated with:

      @MessageDriven(name = "MyListener", messageListenerInterface = javax.jms.MessageListener.class, activationConfig = {

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

              @ActivationConfigProperty(propertyName = "maxSessions", propertyValue = "20"),

              @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/com.myorg.MyQueue") })

       

      The stack's attached:

       

      Any help will be greatly appreciated.

       

      Cheers

      Sam

        • 1. Re: EJBException: Failed to acquire the pool semaphore
          Samuel Tannous Newbie

          This issue was caused by the maxSessions size being larger than the MDB pool size.

           

          With this configuration, the broker was dispatching messages to 20 activeMQ sessions and the sessions were attempting to deliver those 20 messages to 15 listeners. Because our listeners performed long running tasks, sometimes those in the wait queue would timeout.

           

          I could recreate this issue consistently with 20 messages, 20 sessions and 5 listeners that slept for 30 seconds. I would see 5 messages received by the listeners and then after 10 seconds, the other 15 messages would error with "Failed to acquire the pool semaphore". Setting maxSessions to 5 resolves the issue as the broker will only attempt to deliver 5 messages at a time (remembering we also have prefetch set to 0).

           

          I hope this helps someone.

           

          Sam