
The Payara Monthly Catch -September 2025
Welcome aboard the September issue of The Monthly Catch! With summer holidays wrapping up, the Java world is back […]
In prior releases of Payara Server, it was not possible to control the maximum number of concurrent Stateless EJB instances in Payara Server. It was, however, possible to control the number of pooled Stateless EJB instances, as well as concurrent MDB instances. These features were available in Oracle GlassFish Server 3.1 and earlier but not in the GlassFish Open Source editions (3.1.2.x and 4.x).
In the current release of Payara Server (171), it is now possible to limit concurrent Stateless EJB instances that are dispatched, allowing fine-grained control of resources, limiting surface area for DDOS attacks and making applications run more smoothly and efficiently.
The key difference is that previously it was not possible to limit the number of concurrent threads dispatched for the same Stateless EJB, the only limit was the number of pooled beans. When the pool ran out, new EJB instances were created, with no upper bound. In the current release, this upper bound can be established so the maximum number of threads is not exceeded beyond this value.
These limits are controlled on a per-EJB basis, using bean-pool
elements in the glassfish-ejb-jar.xml
deployment descriptor file:
<max-pool-size>
This element controls the maximum concurrent instances that are dispatched for this EJB (number of threads). The default is configured in the domain; this has not changed from previous versions.<max-wait-time-in-millis>
This element controls what to do when the number of requests exceeds the amount of beans available in the pool. This is a new feature.
Additionally, a new system property fish.payara.ejb-container.max-wait-time-in-millis
can be set to change the default global value of <max-wait-time-in-millis>
for all Stateless EJB bean pools. Unless overridden in the deployment descriptor file, this will become the new default value and can be used to cap the upper bound of all concurrent invocations of any Stateless EJB pools.
The <steady-pool-size>
element controls the minimum number of beans in the bean pool. This will increase performance at the expense of memory footprint.
Here’s a complete example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-ejb-jar PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 EJB 3.1//EN" "http://glassfish.org/dtds/glassfish-ejb-jar_3_1-1.dtd">
<glassfish-ejb-jar>
<enterprise-beans>
<ejb>
<ejb-name>PooledStatelessBean</ejb-name>
<bean-pool>
<max-pool-size>1</max-pool-size>
<max-wait-time-in-millis>0</max-wait-time-in-millis>
<!--<steady-pool-size>1</steady-pool-size>-->
</bean-pool>
</ejb>
<ejb>
<ejb-name>PooledMDB</ejb-name>
<bean-pool>
<max-pool-size>1</max-pool-size>
<resize-quantity>1</resize-quantity>
</bean-pool>
</ejb>
</enterprise-beans>
</glassfish-ejb-jar>
{{cta(‘8a4f0637-38ea-458c-a66c-6307d6f21923’)}}
Share:
Welcome aboard the September issue of The Monthly Catch! With summer holidays wrapping up, the Java world is back […]
We’re excited to announce that Payara Platform Community 7 Beta application server is now fully certified as Jakarta EE 11 […]
Enterprise Java applications power global commerce, healthcare, government and countless other industries. These systems must be scalable, secure and […]
Is it possible to annotate a MDB equivalent to this:
@MessageDriven(mappedName = QUEUENAME, activationConfig = {
@ActivationConfigProperty(propertyName = “maxSession”, propertyValue = “1”)})
public class StatisticDeleteService implements MessageListener {
…
}
?
Yes, you can use annotations as well.
See this Oracle documentation link: https://docs.oracle.com/cd/E19879-01/821-0185/gbtvf/index.html
Specifically, you can use @ActivationConfigProperty(propertyName = “MaxPoolSize”) and @ActivationConfigProperty(propertyName = “MaxWaitTime”) to achieve desired effect.
Alternatively, you can use glassfish-ejb-jar.xml file with the syntax described above to control the number of running simultaneous MDB instances.
Thanks for your answer.
I tried this, but sadly it gives me the following warnings on deploying:
Warning: RAR8000 : The method setMaxPoolSize is not present in the class : com.sun.messaging.jms.ra.ActivationSpec
Warning: RAR7097: No setter method present for the property MaxPoolSize in the class com.sun.messaging.jms.ra.ActivationSpec
Warning: RAR8000 : The method setMaxWaitTime is not present in the class : com.sun.messaging.jms.ra.ActivationSpec
Warning: RAR7097: No setter method present for the property MaxWaitTime in the class com.sun.messaging.jms.ra.ActivationSpec
That’s unfortunate. Feel free to open an issue.
Meanwhile, you can use glassfish-ejb-jar.xml file