Search code examples
javaactivemq-classicspring-jmsconsumer

Only one ActiveMQ session is handling messages


In a project, I am using ActiveMQ to process a relatively large number of messages. For that purpose there is a queue, fooQueue, which contains the messages to be processed.

Two instances of an application are processing messages from that queue, using Spring JMS. I have a DefaultMessageListenerContainer set up in the following way.

DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
container.setConnectionFactory(connectionFactory);
container.setDestinationName(QUEUE_NAME);
container.setMessageListener(myMessageListener);
container.setConcurrency(getProperty("concurrency"));
container.setSessionTransacted(true);
container.setErrorHandler(new ErrorHandler());
return container;

By looking at the AMQ web console, I can confirm that the correct number of consumers and sessions are created (session/consumer). However, it appears as if one session is doing most job, which leads to the application being frozen at times.

That session enqueues and dequeues most messages, all others far less then it. If I restart one of those two application instances, one session in the app instance picks up the work, and behaves the same.

Besides checking if myMessageListener is blocking, is there anything else I can do?


Solution

  • We have tried various settings, increasing the memory, using separate KahaDB instances for every queue etc. but nothing helped. What helped was to split the queue.