9 Replies Latest reply on Aug 22, 2016 12:54 PM by berhauz

    Setting max pool size in Jboss 7.1.0.Beta1

    zenzei2k

      I need to set the max pool size to one (1) for a scheduler bean. How can I do that in Jboss 7.1 with annotations?

       

      I tried with @PoolClass (value=org.jboss.as.ejb3.pool.strictmax.StrictMaxPool.class, maxSize=1) but it doesn't work because the @PoolClass expects a class implementing org.jboss.ejb3.Pool, but now the interface Pool is in org.jboss.as.ejb3.pool package.

       

      Thanks in advance!

        • 1. Re: Setting max pool size in Jboss 7.1.0.Beta1
          zenzei2k

          Sorry, anyone has any clues?

          • 2. Re: Setting max pool size in Jboss 7.1.0.Beta1
            jaikiran

            7.1.0.Beta1 doesn't currently have the support for setting up individual beans with pool references. However, I just finished adding that support in my branch here https://github.com/jaikiran/jboss-as/commits/ejb-pool. I'll have to get it pushed upstream this coming week and then you can start configuring the individual EJBs for pools either via the @org.jboss.ejb3.annotation.Pool (which by the way doesn't have the same attributes as before) or via the jboss-ejb3.xml deployment descriptor as follows:

             

            @Stateless
            @org.jboss.ejb3.annotation.Pool(value="NameOfSomePoolConfiguredInTheEJB3Subsystem")
            public class MyBean....
            {
            ....
            

             

            or deployment descriptor (jboss-ejb3.xml):

             

            <jboss xmlns="http://java.sun.com/xml/ns/javaee"
                xmlns:p="urn:ejb-pool:1.0">
            .... 
                <assembly-descriptor>
                    <p:pool>
                        <ejb-name>MyBean</ejb-name>
                        <p:bean-instance-pool-ref>NameOfSomePoolConfiguredInTheEJB3Subsystem</p:bean-instance-pool-ref>
                    </p:pool>
                </assembly-descriptor>
            </jboss>
            

             

            or even this, if you want to apply it to all EJBs in that deployment (notice the <ejb-name>*</ejb-name> part):

             

            <jboss xmlns="http://java.sun.com/xml/ns/javaee"
                xmlns:p="urn:ejb-pool:1.0">
            .... 
                <assembly-descriptor>
                    <p:pool>
                        <ejb-name>*</ejb-name>
                        <p:bean-instance-pool-ref>NameOfSomePoolConfiguredInTheEJB3Subsystem</p:bean-instance-pool-ref>
                    </p:pool>
                </assembly-descriptor>
            </jboss>
            

             

            So the examples above are setting up a bean to refer to some pool configuration which is setup in the EJB3 subsystem in standalone.xml/domain.xml. For example:

             

            <subsystem xmlns="urn:jboss:domain:ejb3:1.2">
            ...
                <pools>
                    <bean-instance-pools>
                        <strict-max-pool name="TheCustomPoolNameThatWillBeUsedInTheEJBDeploymentDescriptorOrAnnotation" max-pool-size="10" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="SECONDS"/>
            ...
                </pools>
            ....
            
            • 3. Re: Setting max pool size in Jboss 7.1.0.Beta1
              zenzei2k

              Thanks for your response jaikirian. I'll wait for the update then and try again. Do you have any idea when the new version with this fixes will be available?

               

              Best regards,

              • 4. Re: Setting max pool size in Jboss 7.1.0.Beta1
                tcoates1362

                Do I need to create a bean-instance-pools entry for each EJB that I want to limit the pool size on? For example, if I had 5 MDBs which I wanted to limit to one instance each, do I need to create this?:

                 

                {code:xml}

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

                ...

                    <pools>

                        <bean-instance-pools>

                            <strict-max-pool name="MDB1Pool" max-pool-size="1" instance-acquisition-timeout="30" instance-acquisition-timeout-unit="SECONDS"/>

                            <strict-max-pool name="MDB2Pool" max-pool-size="1" instance-acquisition-timeout="30" instance-acquisition-timeout-unit="SECONDS"/>

                            <strict-max-pool name="MDB3Pool" max-pool-size="1" instance-acquisition-timeout="30" instance-acquisition-timeout-unit="SECONDS"/>

                            <strict-max-pool name="MDB4Pool" max-pool-size="1" instance-acquisition-timeout="30" instance-acquisition-timeout-unit="SECONDS"/>

                            <strict-max-pool name="MDB5Pool" max-pool-size="1" instance-acquisition-timeout="30" instance-acquisition-timeout-unit="SECONDS"/>

                ...

                    </pools>

                {code}

                 

                In older AS versions, I could do this on each MDB:

                 

                {code:java}@PoolClass (value=org.jboss.ejb3.StrictMaxPool.class, maxSize=1){code}

                 

                Is there anyway to do something similar without defining specific bean pools?

                • 5. Re: Setting max pool size in Jboss 7.1.0.Beta1
                  zenzei2k

                  I also like the old configuration with annotations, but i think is not possible right now, so yes, you have to configure them in xml.

                  • 6. Re: Setting max pool size in Jboss 7.1.0.Beta1
                    jbertram

                    In 7.1.1 you can use the org.jboss.ejb3.annotation.Pool annotation.  However, this just points to the pool configured in the XML.  It doesn't allow you to configure the actual pool values.  That said, I believe this is likely much better for management and tuning later on since you won't have pool size values set in code.

                    • 7. Re: Setting max pool size in Jboss 7.1.0.Beta1
                      librucha

                      Hi.

                      I thing better is use annotation @Singleton. Your bean will be only one in whole appliacation.

                      • 8. Re: Setting max pool size in Jboss 7.1.0.Beta1
                        acwest

                        I have too questions about configuring the bean-instance-pools. The first is, is each of these pools per bean type? for example (and this was mentioned n another question) would a pool configured as:

                        <strict-max-pool name="MDBSingletonPool" max-pool-size="1" instance-acquisition-timeout="30" instance-acquisition-timeout-unit="SECONDS"/>

                        create a separate pool for every MDB bean type configured to use it, or one pool for all beans that are configured to use it.

                        Also, how does this interact with the maxSessions ActivationConfigProperty? Is the default maxSessions still 15, even if the MDB uses the @Pool annotation to use a pool that has a different size? Most of the documentation I have found seems to indicate that maxSessions and pool size should match, so it doesn't make sense to split up the configuration between the java code and the standalone-full-ha.xml file.

                        • 9. Re: Setting max pool size in Jboss 7.1.0.Beta1
                          berhauz

                          It seems from Is Message Driven Bean (MDB) restrained by the thread-pool definition in "ejb3" subsystem ? - Red Hat Customer Portal that defining a strict-max-pool once is enough, and each bean pointing to this definition will have up to strict-max-pool instances running at one time. Number of threads allocated to the container (usually smaller than number-of-deployed-beans*max-pool) may then cause many bean instances in pools to be queued for work.