[英]Spring JMS listener receives empty messages causing CPU consumption
I'm working on an application that uses a couple of jms queues to send/receive updates to/from an external system. 我正在使用几个jms队列向/从外部系统发送/接收更新的应用程序。 In order to test my application I'm using Mockrunner and specifically the jms module.
为了测试我的应用程序,我使用了Mockrunner,特别是jms模块。 I'm facing a strange behavior: when I start my application I can see the CPU skyrocketing at 100% and, by analyzing thread dumps, I can see that the main reason is related to the jms listeners I have that looks like receiving empty messages this causing messages like:
我面临一个奇怪的行为:启动我的应用程序时,我可以看到CPU以100%的速度飙升,并且通过分析线程转储,我可以看到主要原因与我拥有的jms侦听器有关,就像接收空消息一样这会导致如下消息:
Consumer ... did not receive a message
Now I'm trying to understand if the issue is related to a bad interaction of my app and mockrunner or is a configuration error. 现在,我试图了解该问题是否与我的应用程序与模拟运行器的不良互动有关,还是配置错误。
The relevant parts of the configuration are: 配置的相关部分是:
<bean id="destinationManager" factory-bean="mockRunnerJMSObjectFactory" factory-method="getDestinationManager" />
<bean id="mockJmsConnectionFactory" factory-bean="mockRunnerJMSObjectFactory" factory-method="createMockConnectionFactory" lazy-init="true"/>
and the listener that cause the CPU to spin indefinitely are: 导致CPU无限旋转的监听器是:
<jms:listener-container concurrency="5" connection-factory="mockJmsConnectionFactory" destination-type="queue" message-converter="myMessageConverter" acknowledge="transacted" >
<jms:listener
id="myListener"
destination="myQueue"
ref="myConsumer"
method="consume"
/>
</jms:listener-container>
<bean id="myConsumer"... />
UPDATE I opened an issue on Mockrunner project, you can see it here . 更新我在Mockrunner项目上打开了一个问题,您可以在此处查看 。
After some investigation I found out that the problem lies in a bad interaction with Spring DefaultMessageListenerContainer
. 经过一番调查,我发现问题出在与Spring
DefaultMessageListenerContainer
的不良交互。 That Listener has a polling-based implementation and, given that the mocked infrastructure is very fast when answering requests, cause the CPU to overload. 该侦听器具有基于轮询的实现,并且鉴于模拟的基础结构在答复请求时非常快,因此会导致CPU过载。 I patched mock runner by adding an ugly thread sleep in the response method, maybe this is going to be fixed sooner or later.
我通过在响应方法中添加一个丑陋的线程睡眠来修补模拟运行器,这也许迟早会得到解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.