4 Replies Latest reply on Mar 7, 2011 3:14 PM by Michael Moore

    Adjust / reduce MDB bean pool

    Alexander Hartner Expert

      I am trying to reduce the MDB bean pool to limit the concurrency of my application. I know I can do this via the ActivationSpecification as well as via the deployment descriptor. However I would like to do this outside the EAR file and be able to adjust it at the application server level. I have found the suggestion to edit maxSize=5 in ejb3-interceptors-aop.xml.

       

       

            <bind pointcut="execution(public * @javax.annotation.security.RunAs->*(..))">
               <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
            </bind>
            <bind pointcut="execution(public * *->*(..))">
               <interceptor-ref name="org.jboss.ejb3.stateless.StatelessInstanceInterceptor"/>
               <interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
               <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
               <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
               <interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
            </bind>
            <annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
               @org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.StrictMaxPool.class, maxSize=5, timeout=10000)
            </annotation>
         </domain>

         <domain name="Message Driven Bean">

            <bind pointcut="execution(public * @javax.annotation.security.RunAs->*(..))">

               <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>

            </bind>

            <bind pointcut="execution(public * *->*(..))">

               <interceptor-ref name="org.jboss.ejb3.stateless.StatelessInstanceInterceptor"/>

               <interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>

               <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>

               <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>

               <interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>

            </bind>

            <annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">

               @org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.StrictMaxPool.class, maxSize=5, timeout=10000)

            </annotation>

         </domain>

       

      Yet this resulted the following exception:

       

       

      javax.ejb.EJBException: Failed to acquire the pool semaphore, strictTimeout=10000

              at org.jboss.ejb3.StrictMaxPool.get(StrictMaxPool.java:122)

              at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

              at org.jboss.ejb3.mdb.MessagingContainer.localInvoke(MessagingContainer.java:249)

              at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.delivery(MessageInflowLocalProxy.java:268)

              at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.invoke(MessageInflowLocalProxy.java:138)

              at $Proxy158.onMessage(Unknown Source)

              at org.jboss.resource.adapter.jms.inflow.JmsServerSession.onMessage(JmsServerSession.java:178)

              at org.jboss.jms.client.container.ClientConsumer.callOnMessageStatic(ClientConsumer.java:160)

              at org.jboss.jms.client.container.SessionAspect.handleRun(SessionAspect.java:831)

              at org.jboss.aop.advice.org.jboss.jms.client.container.SessionAspect14.invoke(SessionAspect14.java)

              at org.jboss.jms.client.delegate.ClientSessionDelegate$run_N8003352271541955702.invokeNext(ClientSessionDelegate$run_N8003352271541955702.java)

              at org.jboss.jms.client.container.ClosedInterceptor.invoke(ClosedInterceptor.java:170)

              at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:105)

              at org.jboss.jms.client.delegate.ClientSessionDelegate$run_N8003352271541955702.invokeNext(ClientSessionDelegate$run_N8003352271541955702.java)

              at org.jboss.jms.client.delegate.ClientSessionDelegate.run(ClientSessionDelegate.java)

              at org.jboss.jms.client.JBossSession.run(JBossSession.java:199)

              at org.jboss.resource.adapter.jms.inflow.JmsServerSession.run(JmsServerSession.java:237)

              at org.jboss.resource.work.WorkWrapper.execute(WorkWrapper.java:204)

              at org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:275)

              at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:756)

              at java.lang.Thread.run(Thread.java:619)

       


      Further reading brought me on to this link : http://community.jboss.org/wiki/ConfigJBossMDB as well as other forum posts which suggests adding <strictTimeout>forever</strictTimeout> to conf/standardjboss.xml as in:


       

        <container-configuration>

            <container-name>Standard Message Driven Bean</container-name>

            <call-logging>false</call-logging>

            <invoker-proxy-binding-name>message-driven-bean</invoker-proxy-binding-name>

            <container-interceptors>

              <interceptor>org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor</interceptor>

              <interceptor>org.jboss.ejb.plugins.LogInterceptor</interceptor>

              <interceptor>org.jboss.ejb.plugins.RunAsSecurityInterceptor</interceptor>

              <!-- CMT -->

              <interceptor transaction="Container">org.jboss.ejb.plugins.TxInterceptorCMT</interceptor>

              <interceptor transaction="Container">org.jboss.ejb.plugins.CallValidationInterceptor</interceptor>

              <interceptor transaction="Container">org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor</interceptor>

              <!-- BMT -->

              <interceptor transaction="Bean">org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor</interceptor>

              <interceptor transaction="Bean">org.jboss.ejb.plugins.MessageDrivenTxInterceptorBMT</interceptor>

              <interceptor transaction="Bean">org.jboss.ejb.plugins.CallValidationInterceptor</interceptor>

              <interceptor>org.jboss.resource.connectionmanager.CachedConnectionInterceptor</interceptor>

            </container-interceptors>

            <instance-pool>org.jboss.ejb.plugins.MessageDrivenInstancePool</instance-pool>

            <instance-cache></instance-cache>

            <persistence-manager></persistence-manager>

            <container-pool-conf>

                 <MaximumSize>100</MaximumSize>

                 <strictTimeout>forever</strictTimeout>

            </container-pool-conf>

          </container-configuration>

       

      Yet this did not fix the exception. It seems increasing the bean pool size above 15 works, however reducing it to say 5 causes the exception.

       

      Any suggestion on how I to change the pool size used for MDBs using JBoss 4.2.3 correctly.

       

      Kind regards

      Alex

        • 1. Re: Adjust / reduce MDB bean pool
          Alexander Hartner Expert

          I posted about the same issue a while back when I was trying to increase the bean pool here http://community.jboss.org/message/355781#355781 which directed me here for http://community.jboss.org/message/439028#439028 solution. This suggestions adding the strictTimout which does not work in my case. Then it occurred to me that I was using JBoss messaging (JBoss Messaging 1.4.2.GA-SP1) rather then the default messaging engine. In retrospect I feel rather silly for not mentioning this earlier. However I am still stuck. I tried looking at the JBoss Messaging documentation but could not find a way to change the pool size.

           

          Thanks in advance

          Alex

          • 2. Re: Adjust / reduce MDB bean pool
            Alexander Hartner Expert

            Setting the pool to 14 and the timeout to 12500 as follows:

            @org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.StrictMaxPool.class, maxSize=14, timeout=12500)

            I get the following exception:

            javax.ejb.EJBException: Failed to acquire the pool semaphore, strictTimeout=12500
                    at org.jboss.ejb3.StrictMaxPool.get(StrictMaxPool.java:122)
                    at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54)
                    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                    at org.jboss.ejb3.mdb.MessagingContainer.localInvoke(MessagingContainer.java:249)
                    at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.delivery(MessageInflowLocalProxy.java:268)
                    at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.invoke(MessageInflowLocalProxy.java:138)
                    at $Proxy155.onMessage(Unknown Source)
                    at org.jboss.resource.adapter.jms.inflow.JmsServerSession.onMessage(JmsServerSession.java:178)
                    at org.jboss.jms.client.container.ClientConsumer.callOnMessageStatic(ClientConsumer.java:160)
                    at org.jboss.jms.client.container.SessionAspect.handleRun(SessionAspect.java:831)
                    at org.jboss.aop.advice.org.jboss.jms.client.container.SessionAspect14.invoke(SessionAspect14.java)
                    at org.jboss.jms.client.delegate.ClientSessionDelegate$run_N8003352271541955702.invokeNext(ClientSessionDelegate$run_N8003352271541955702.java)
                    at org.jboss.jms.client.container.ClosedInterceptor.invoke(ClosedInterceptor.java:170)
                    at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:105)
                    at org.jboss.jms.client.delegate.ClientSessionDelegate$run_N8003352271541955702.invokeNext(ClientSessionDelegate$run_N8003352271541955702.java)
                    at org.jboss.jms.client.delegate.ClientSessionDelegate.run(ClientSessionDelegate.java)
                    at org.jboss.jms.client.JBossSession.run(JBossSession.java:199)
                    at org.jboss.resource.adapter.jms.inflow.JmsServerSession.run(JmsServerSession.java:237)
                    at org.jboss.resource.work.WorkWrapper.execute(WorkWrapper.java:204)
                    at org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:275)
                    at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:756)
                    at java.lang.Thread.run(Thread.java:619)

             

            javax.ejb.EJBException: Failed to acquire the pool semaphore, strictTimeout=12500

                    at org.jboss.ejb3.StrictMaxPool.get(StrictMaxPool.java:122)

                    at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54)

            So this seem to be the right place to change it. It seems that there is another place somewhere which expects this pool to be set to 15 and when it can't get all 15 instances it waits for the timeout period and then gives up. Given that this is an MDB it should keep the messages on the queue and then pull them off when a bean becomes available.

            • 3. Re: Adjust / reduce MDB bean pool
              Alexander Hartner Expert

              Using :

              @org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.StrictMaxPool.class, maxSize=5, timeout=2400000)

              seems to have done the trick. Setting a much larger timeout allowed me to process the messages without exceptions. I am however not sure this is the best option of doing this.

              • 4. Adjust / reduce MDB bean pool
                Michael Moore Newbie

                I suppose this is too late to help the original poster, but in case anyone else has this issue:

                 

                The problem is most likely that the session pool is larger than your MDB pool.   The session pool size is set to 15 by default.

                 

                The session pool size is controlled by the "maxSession" activation configuration property.