6

I wrote a JMS application that runs within a web service in Glassfish (also deployed it in JBoss), I noticed that after I process several messages through a MessageListener MDP, the JMS server runs out of connections!

Tried it with both Apache ActiveMQ and Glassfish internal JMS broker (openMQ?)

Is there a way to check why this is happening? If this is the default behavior of JmsTemplate, what is my alternative for developing JMS producers and consumers the right way?

Thanks!

wsb3383
  • 3,841
  • 12
  • 44
  • 59
  • 1
    Perhaps you are asking the same question (http://stackoverflow.com/questions/4046840/spring-jmstemplate-and-apache-activemq-why-so-many-connections) differently? – Raghuram Nov 02 '10 at 05:31
  • Yes, I am, after investigating it, I thought it was an ActiveMQ issue first. – wsb3383 Nov 02 '10 at 16:58

2 Answers2

4

The spring JMSTemplate will close and create all resources (Connections, Consumers, Producers ..) each time it receives or sends a message. This will be a huge performance bottleneck if you are not using pooled Connections, Sessions, Consumers .... .

Having said that, yes the JMSTemplate should close your connection each time.

Oliver
  • 126
  • 2
1

Yes, the connection gets closed. See the code of the execute method:

JmsUtils.closeSession(sessionToClose);
ConnectionFactoryUtils.releaseConnection(
    conToClose, getConnectionFactory(), startConnection);
Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140