1
votes

I've done some tests with ActiveMQ and Spring JMS. I've configured DefaultMessageListenerContainer (DMLC) with WorkManagerTaskExecutor and CommonJ to manage the threads. I want to have control over the threads are running in the server.

I have made the decision of using DMLC based on a post written by Juergen Holler in Spring's forum: http://forum.spring.io/forum/other-spring-related/remoting/24208-what-s-the-best-practice-for-using-jms-in-spring?p=256420#post256420

In this post, he says "DMLC is the only listener container that does not impose the thread management onto the JMS provider, that is, does not use/block JMS provider threads." So I thought that all the threads would be managed by the server and there wouldn't be threads of ActiveMQ.

However, analysing the server's threads using JConsole, I've seen some threads of ActiveMQ that I didn't expect.

enter image description here

As you can see in the image, there are ActimeMQ threads (inactivity threads, transport threads, etc).

When I'm executing the tests, I see in the logs that the JMS messages are processed by CommonJ threads and not by ActiveMQ threads, so that's fine. However, I don't understand why are ActiveMQ threads are created if they are not used. Specially "ActiveMQ Transport" threads because for every queue I use I've got one thread "ActiveMQ Transport". Therefore if I'm consuming 50 queues, I've got 50 threads of "ActiveMQ Transport". Is it to keep the socket opened? Are these threads mandatory?

Details about the configuration:

  • ConnectionFactory used: org.apache.activemq.ActiveMQConnectionFactory
  • ActiveMQ version: 5.11.1
  • Transport protocol: TCP
  • Using DefaultMessageListenerContainer the client is in a loop invoking MessageConsumer.receive() method.

It seems a silly question and surely I've misunderstood some basic concepts.

1
Check if the ActiveMQ clients are releasing the unused connections. Suspect this could be the case. Are you using a ActiveMq PooledConnectionFactory ? Please add the details of your activeMq versio n and client configuration.Ashoka

1 Answers

1
votes

Thanks to Rob Davies' explanation in this thread http://activemq.2283324.n4.nabble.com/ActimeMQ-Client-s-thread-management-td4705885.html, I've understood that all the interaction with ActiveMQ require a TCP thread per connection.

However, the amount of transport threads can be minimised replacing ActiveMQConnectionFactory with one of these ConnectionFactories:

  • PooledConnectionFactory (ActiveMQ)
  • SingleConnectionFactory (spring-jms)
  • CachingConnectionFactory (spring-jms)