Assign a pool to a specific stateless bean in JBos

2019-07-24 05:32发布

问题:

I can see how one can control the size of the global pool for all the stateless session beans.

However, I would like to be able to have a new pool that only applies to one type of stateless bean. This way, all my stateless beans but one would be pooled from the usual slsb-strict-max-pool, and one bean would have its own pool.

Is it possible to do that in JBoss EAP 6.1?

回答1:

Use

@org.jboss.ejb3.annotation.Pool(value="myPoolName")

annotation on the EJB referencing your custom pool as defined in the standalone.xml :

<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="80" instance-acquisition-timeout="1"
                                 instance-acquisition-timeout-unit="MINUTES" />
                <strict-max-pool name="myPoolName"
                                 max-pool-size="20" instance-acquisition-timeout="5"
                                 instance-acquisition-timeout-unit="SECONDS" />
            </bean-instance-pools>
</pools>

[edit] without the annotation :

Using the pool namespace (urn:ejb-pool:1.0) in jboss-ejb3.xml (jboss specific ejb descriptor)

<p:pool>
 <ejb-name>myEjbName</ejb-name>
 <p:bean-instance-pool-ref>myPoolName</p:bean-instance-pool-ref>
</p:pool>


回答2:

Finally, it seems you also have to configure the 'maxSession' activation configuration property accordingly in your MDB. Default maxSession value is 15. https://docs.jboss.org/ejb3/docs/tutorial/1.0.7/html/Message_Driven_Beans.html

E.g.

  <message-driven>
     <ejb-name>myMDB</ejb-name>                       
        <activation-config>
            <activation-config-property>
                <activation-config-property-name>destination</activation-config-property-name>
                <activation-config-property-value>java:jboss/queue/test/myMDBQueue</activation-config-property-value>
            </activation-config-property>
        <activation-config-property>
                <activation-config-property-name>maxSession</activation-config-property-name>
                <activation-config-property-value>20</activation-config-property-value>
            </activation-config-property>
        </activation-config>
  </message-driven>