I created a skeleton app with a single MDB and setup a fresh 4.1.2.173 with the ActiveMQ RAR - only 5 messages are ever processed concurrently. I am using ActiveMQ 5.15.4.
I ran into that max 10 messages before - that was my first assumption that I screwed-up the configuration. Whether I change the maxSessions or not makes no difference. I haven't been able to reach 10 yet! I have tinkered with every parameter I could find - prefetch etc.
To test the concurrency, I added a sleep into the MDB. In my clean environment, when the bean finishes processing a message, the exception below appears.
[2018-08-14T15:51:30.109-0400] [Payara 4.1] [SEVERE] [] [javax.enterprise.system.container.ejb.mdb.org.glassfish.ejb.mdb] [tid: _ThreadID=257 _ThreadName=__ejb-thread-pool16] [timeMillis: 1534276290109] [levelValue: 1000] [[
java.lang.reflect.InvocationTargetException
java.lang.reflect.InvocationTargetException
at com.sun.ejb.containers.BaseContainer.createEjbInstanceAndContext(BaseContainer.java:1659)
at org.glassfish.ejb.mdb.MessageBeanContainer.createMessageDrivenEJB(MessageBeanContainer.java:767)
at org.glassfish.ejb.mdb.MessageBeanContainer.access$100(MessageBeanContainer.java:126)
at org.glassfish.ejb.mdb.MessageBeanContainer$MessageBeanContextFactory.create(MessageBeanContainer.java:529)
at com.sun.ejb.containers.util.pool.NonBlockingPool.preload(NonBlockingPool.java:314)
at com.sun.ejb.containers.util.pool.NonBlockingPool.doResize(NonBlockingPool.java:558)
at com.sun.ejb.containers.util.pool.NonBlockingPool$IdleBeanWork.run(NonBlockingPool.java:657)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
at com.sun.ejb.containers.BaseContainer.injectEjbInstance(BaseContainer.java:1718)
at com.sun.ejb.containers.BaseContainer.createEjbInstanceAndContext(BaseContainer.java:1652)
... 11 more
My test MDB: (note, I didn't set the maxSessions, tried but didn't make a difference)
@MessageDriven(
activationConfig = {
@ActivationConfigProperty(propertyName="destinationType",propertyValue="javax.jms.Queue"),
@ActivationConfigProperty(propertyName="destination",propertyValue="trainingQueue")
}
)
public class OrderProcessorMDB {
private static AtomicInteger counter = new AtomicInteger(0);
private int myNumber;
@PostConstruct
public void init() {
myNumber = counter.incrementAndGet();
}
public void onMessage(Message message) {
TextMessage tm = (TextMessage)message;
try {
System.out.println("Count: " + myNumber + " msg: " + tm.getText());
} catch (JMSException e) {
e.printStackTrace();
}
try {
Thread.sleep(300000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("Resuming...");
}
}