Custom pool configuration for your EJBs on JBoss AS 7/WildFly

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active
 

Stateless session beans are held in a pool which can be configured at EJB Container level. You can define as many pool configuration as you want and then decide which one to use for your EJB container.

One thing which if often requested is to apply some specific settings for a particular EJB.

With JBoss AS 7 /EAP 6 and WildFly it is possible to apply some specific pool settings by decorating your class with the @org.jboss.ejb3.annotation.Pool annotation:

import org.jboss.ejb3.annotation.Pool;

@Stateless
@Pool(value="poolcustom") 

public class  ServiceBean   {
. . .
}

 The value for the pool needs to be defined in your server configuration:

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

 Please note that you can also define the Pool size using the jboss-ejb3.xml file as follows:

<jboss:ejb-jar xmlns:jboss="http://www.jboss.com/xml/ns/javaee" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="urn:ejb-pool:1.0" xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-ejb3-2_0.xsd http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd
http://www.jboss.org/j2ee/schema/jboss_5_0.xsd" version="3.1" impl-version="2.0">
	<assembly-descriptor>
		<p:pool>
			<ejb-name>ServiceBean</ejb-name>
			<p:bean-instance-pool-ref>poolcustom2</p:bean-instance-pool-ref>
		</p:pool>
 
	</assembly-descriptor>
</jboss:ejb-jar>

 

Related articles available on mastertheboss.com

EJB 3.0 tutorial : Session Beans

Enterprise JavaBeans (EJB) technology is a J2EE technology for de

JBoss MDB 3.0

Message-driven beans (MDBs) are stateless, server-side, transacti

JBoss EJB 3 BMT

In a Bean Managed Transaction, the code in the session or message

How do you keep your EJB callbacks separated from biz. methods?

JBoss daily recipe

How to set EJB timeout period ?

JBoss recipe of the day

How to add a Selector with MDB 3.0 ?

Message selectors allow an MDB to be more selective about the mes

Follow us on Twitter