Spring JmsTemplate 和 Apache ActiveMQ,为什么有这么多连接?

发布于 2024-09-29 05:26:56 字数 635 浏览 2 评论 0原文

我有一个 Web 应用程序,一旦在 ActiveMQ 上收到消息(由 Spring MessageListener 侦听),该应用程序就会在后台运行文本处理作业......我遇到的问题是,一旦我处理大约 30 个后台作业,ActiveMQ停止处理任何消息,Spring 消息侦听器丢失其 JMS 连接,有时我在 ActiveMQ 日志中收到错误消息,指出

我在 Linux 上针对 ActiveMQ 进程运行了“lsof”(列出打开文件)命令 。并注意到对于 JmsTemplate 排队/发布/接收的几乎每条消息,都会打开一个新连接,这

是我的配置吗?

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

I have a web application that runs text processing jobs in the background once a message is received on an ActiveMQ which is listened to by a Spring MessageListener....the problem I"m encountering is that once I process around 30 background jobs, ActiveMQ stops processing any messages, Spring message listener loses its JMS connection, and sometimes I get an error in the ActiveMQ log saying that there are too many open files.

I ran the 'lsof' (list open file) command on Linux against the ActiveMQ process and noticed that for almost each message queued/published/received by JmsTemplate, a new connection is opened. Is this normal?

here's 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>

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

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

发布评论

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

评论(1

烙印 2024-10-06 05:26:56

需要使用ActiveMQ提供的PooledConnectionFactory,完整配置可以这里查看< /a>.请务必阅读 JmsTemplate 陷阱

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

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