开发者

Does Spring JmsTemplate close connections by default?

开发者 https://www.devze.com 2023-01-23 05:42 出处:网络
I wrote a JMS application that runs within a web service inGlassfish (also deployed it in JBoss), I noticed that after I process several messages through a MessageListener MDP, the JMS server runs out

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 happ开发者_如何转开发ening? If this is the default behavior of JmsTemplate, what is my alternative for developing JMS producers and consumers the right way?

Thanks!


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.


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

JmsUtils.closeSession(sessionToClose);
ConnectionFactoryUtils.releaseConnection(
    conToClose, getConnectionFactory(), startConnection);
0

精彩评论

暂无评论...
验证码 换一张
取 消