Does Spring JmsTemplate close connections by default?
Asked Answered
G

2

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!

Germanic answered 1/11, 2010 at 23:58 Comment(2)
Perhaps you are asking the same question (#4047340) differently?Yim
Yes, I am, after investigating it, I thought it was an ActiveMQ issue first.Germanic
T
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.

Tungstic answered 5/2, 2011 at 10:48 Comment(0)
I
1

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

JmsUtils.closeSession(sessionToClose);
ConnectionFactoryUtils.releaseConnection(
    conToClose, getConnectionFactory(), startConnection);
Infinite answered 2/11, 2010 at 5:54 Comment(1)
So why do the connections remain open on the JMS server?Germanic

© 2022 - 2024 — McMap. All rights reserved.