Spring JmsTemplate and Apache ActiveMQ, why are there so many connections?

I have a web application that executes text processing jobs in the background after receiving a message in ActiveMQ, which is listened with Spring MessageListener .... the problem that I encounter is that when I process 30 background jobs, ActiveMQ stops processing any messages, Spring's message listener loses its JMS connection, and sometimes I get an error message in the ActiveMQ log that has too many open files.

I ran the lsof (list open file) command on Linux against the ActiveMQ process and noticed that for almost every message delivered / published / received by JmsTemplate, a new connection opens. This is normal?

here is my configuration:

<bean id="connectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory"> <constructor-arg ref="amqConnectionFactory" /> <property name="exceptionListener" ref="jmsExceptionListener" /> <property name="sessionCacheSize" value="100" /> </bean> 
+4
source share
1 answer

You need to use the PooledConnectionFactory provided by ActiveMQ, you can see the full configuration here . Make sure you read JmsTemplate Gotchas .

+1
source

All Articles