4 Replies Latest reply on Sep 13, 2013 6:18 PM by ffatheranderson

    JBoss AS 7.1.1 EJB3 Pools Configuration

    ifti24

      Is it possible to configuring the pools at individual bean level in AS 7.1.1 ?

      If yes then how ?

       

      If no then do you have any plan for it in the future release ?

        • 1. Re: JBoss AS 7.1.1 EJB3 Pools Configuration
          rhanus

          sure you may configure specific pools for your stateless and message-driven beans

          locate the ejb subsystem in standalone.xml, there are predefined pools used by default:

           

          <subsystem xmlns="urn:jboss:domain:ejb3:1.2">

                      <session-bean>

                          <stateless>

                             <bean-instance-pool-ref pool-name="slsb-strict-max-pool"/>

                          </stateless>

                          <stateful default-access-timeout="5000" cache-ref="simple"/>

                          <singleton default-access-timeout="5000"/>

                      </session-bean>

                      <mdb>

                          <resource-adapter-ref resource-adapter-name="hornetq-ra"/>

                          <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>

                      </mdb>

                      <pools>

                          <bean-instance-pools>

                              <strict-max-pool name="slsb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>

                              <strict-max-pool name="mdb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>

                          </bean-instance-pools>

                      </pools>

          ...

           

          use annotation org.jboss.ejb3.annotation.Pool (available in jboss-ejb3-ext-api-2.0.0.jar) to reference the new pool in your bean class:

           

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

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

                  @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/MyQueue"),

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

          @Pool("mdb-strict-single-pool")

          public class MyHandlerMDB implements MessageListener {

          ....

           

          and add new pool definition into standalone.xml subsystem ejb:

           

                      <pools>

                          <bean-instance-pools>

                              <strict-max-pool name="slsb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>

                              <strict-max-pool name="mdb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>

                              <strict-max-pool name="mdb-strict-single-pool" max-pool-size="1" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>

                          </bean-instance-pools>

                      </pools>

           

          this new bean pool ensures that MyHandlerMDB will be single-threaded !

          see schema $JBOSS_HOME/docs/schema/ejb-jar_3_1.xsd for more details

          • 2. Re: JBoss AS 7.1.1 EJB3 Pools Configuration
            ifti24

            Hi,

             

            Thanks for your quick reply.

            I have one more question to you.

             

            Is three any way to check the current available bean instance count in the pool?

            Suppose in your example you showed that the max pool size for bean MyHandlerMDB is 1.

             

            So I want to see that when ther is a call to MyHandlerMDB then the avaiable bean count is zero for that "mdb-strict-single-pool" .

            • 3. Re: JBoss AS 7.1.1 EJB3 Pools Configuration
              rhanus

              I guess there is no way to check a pool state in bean class and I think it makes no sence at all

              you have no control over pool's runtime so even if there would be an API to obtain current state of a pool then such state is immediately obsolete

              • 4. Re: JBoss AS 7.1.1 EJB3 Pools Configuration
                ffatheranderson

                Is three any way to check the current available bean instance count in the pool?

                Actually you can, by using some profiler, for example visualvm.