Spring JmsTemplate默认关闭连接吗?

发布于 2024-09-30 20:31:23 字数 266 浏览 1 评论 0原文

我编写了一个在 Glassfish 中的 Web 服务中运行的 JMS 应用程序(也将其部署在 JBoss 中),我注意到在通过 MessageListener MDP 处理多条消息后,JMS 服务器耗尽连接!

尝试使用 Apache ActiveMQ 和 Glassfish 内部 JMS 代理(openMQ?)

有没有办法检查为什么会发生这种情况?如果这是 JmsTemplate 的默认行为,那么我以正确的方式开发 JMS 生产者和消费者的替代方案是什么?

谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

憧憬巴黎街头的黎明 2024-10-07 20:31:23

Spring JMSTemplate 将在每次接收或发送消息时关闭并创建所有资源(连接、消费者、生产者..)。
如果您不使用池化连接、会话、消费者……,这将是一个巨大的性能瓶颈。

话虽如此,是的,JMSTemplate 每次都应该关闭您的连接。

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.

孤凫 2024-10-07 20:31:23

是的,连接被关闭。 查看execute方法的代码 :

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

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

JmsUtils.closeSession(sessionToClose);
ConnectionFactoryUtils.releaseConnection(
    conToClose, getConnectionFactory(), startConnection);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文