Custom pool configuration for your EJBs on JBoss AS 7/WildFly
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>
Recommended Articles
Customizing Load Balancing for EJBs in WildFly and JBoss EAP 6
Learn how to customize load balancing for EJBs in WildFly and JBoss EAP 6, including implementing a custom DeploymentNodeSelector for Stateless and Stateful Session Beans.
Mastering JBoss AS and WildFly EJB Annotations: A Comprehensive Cheat Sheet
Discover the power of EJB annotations on JBoss AS and WildFly, from caching to security. Learn how to configure pool sizes, passivation, timeout, and more.
Securing EJBs with Elytron: A Step-by-Step Guide to WildFly Authentication and Authorization
Learn how to configure authentication and authorization for your EJBs on WildFly using the Elytron Security Framework, including HTTP and SASL authentication factories.
Invoke WildFly EJBs from a Remote Client Using JNDI API - Step-by-Step Guide
Learn how to invoke WildFly EJBs remotely using JNDI API. Includes step-by-step instructions and security considerations.