-
1. Re: JBoss AS 7.1.1 EJB3 Pools Configuration
rhanus Nov 20, 2012 4:51 AM (in response to ifti24)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 Nov 21, 2012 3:33 AM (in response to rhanus)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 Nov 21, 2012 5:59 AM (in response to ifti24)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 Sep 13, 2013 6:18 PM (in response to ifti24)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.