@Pool vs maxSession for MDB in JBoss EAP 6
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 6.x
Issue
- We'd like to better understand the relationship between the class annotation @Pool and the @MessageDriven(@ActivationConfigProperty maxSession) for configuring an MDB.
Resolution
maxSession is essentially the maximum number of threads that will be used for the MDBs.
The Pool configuration defines the maximum number of MDB instances that can be created.
If maxSession > instance pool, then the thread will wait for an instance to be available for the instance timeout if all are currently busy.
The instance pool size can be used to limit the number of instances created in the case where the MDB uses a lot of memory.
The JMS JCA resource adapter is responsible for creating the JMS sessions which receive messages from the JMS destinations. These sessions are pooled and the pool size is controlled via the maxSession activation configuration property on the MDB. The default session pool size is 15.
When one of these sessions receives a message it then passes it to the EJB container. The EJB container is responsible for creating the instances of the MDB which process the message via their onMessage(..) method. These instances are pooled and their pool size is controlled via the org.jboss.annotation.ejb.PoolClass annotation in EAP 4.x and the org.jboss.ejb3.annotation.Pool annotation in EAP 5. The default instance pool size is 30 in EAP 4.x and 15 in EAP 5.
Whichever pool size is lower will determine how many messages can be consumed in parallel. It is generally recommended that both of these are set to the same value.
Related Solutions:
How to set an EJB's Instance Pool class via annotation and xml in JBoss EAP 6
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.