How to set EJB3 SLSB and MDB instance pool sizes and timeouts in JBoss EAP 5 / 4

Solution Verified - Updated -

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 5.x
    • 4.x

Issue

  • Set EJB3 MDB instance pool size
  • How do I increase the EJB pool size?
  • How to restrict the number of stateless session beans created per node?
  • What is the default EJB thread pool value in JBoss EAP 5.1. In which file can this value be set in JBoss EAP 5.1?

Resolution

  • The maxSize defaines the EJB thread pool size and the default value is 15.

JBoss EAP 5.x

Using annotations - per EJB

Using annotation @org.jboss.ejb3.annotation.Pool on a particular EJB.

Where the maxSize is the maximum number of pooled instances of the MDB, and the timeout is the number of milliseconds to wait to acquire an instance.

Globally change the default
If it's for all ejbs, make the configuration change in $JBOSS_HOME/server/$PROFILE/deploy/ejb3-interceptors-aop.xml.

There are several configurations such as Stateless Bean and Message Driven Bean where you can change the defaults for all EJBs of a certain type.

@org.jboss.ejb3.annotation.Pool(value="StrictMaxPool", maxSize=20, timeout=4000)

Or use the jboss.xml deployment descriptor:

<?xml version="1.0" encoding="UTF-8"?>
<jboss xmlns="http://java.sun.com/xml/ns/javaee";
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                           http://www.jboss.org/j2ee/schema/jboss_5_0.xsd";
       version="3.0">
   <enterprise-beans>
      <message-driven>
         ...
         <pool-config>
            <pool-value>StrictMaxPool</pool-value>
            <pool-max-size>15</pool-max-size>
            <pool-timeout>10000</pool-timeout>
         </pool-config>
      </message-driven>
   </enterprise-beans>
</jboss>

JBoss EAP 4.x

Using annotations - per EJB
Annotate the EJB with:

@org.jboss.annotation.ejb.PoolClass(value=org.jboss.ejb3.StrictMaxPool.class, maxSize=3, timeout=1000)

Where the maxSize is the maximum number of pooled instances of the EJB, and the timeout is the number of milliseconds to wait to acquire an instance.

Globally change the default
This same configuration is available in $JBOSS_HOME/server/$PROFILE/deploy/ejb3-interceptors-aop.xml in the "Message Driven Bean" domain. However, this file applies to all MDBs by default.

There is no equivalent minSize and EJB pools are not prepopulated, instances are only created when required. However, you can effectively accomplish this by adding your own EJB client calls during startup if you want.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.