高 Spring JMS DefaultMessageListenerContainer.receiveTimeout 参数是什么意思?
What does a high Spring JMS DefaultMessageListenerContainer.receiveTimeout parameter mean?
我正在进入一个实现 IBM MQ 侦听 Spring JMS 应用程序的项目,但我无法理解 DefaultMessageListenerContainer 中的 "receiveTimeout"。
与来自互联网的资源相比,我认为我的项目有点特别,因为我们为 "receiveTimeout" 参数使用了非常高的 30 秒值,但我不知道这实际上意味着什么。
我已经弄明白了"receiveTimeout"参数的含义,下面我会在Spring配置后给大家说说我的理解。
仅供参考:我们 reading/processing 来自队列的许多消息都非常小(大约 100kb)。
这是我们正在使用的 spring 配置:
<bean id="msgListenerContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer"
p:connectionFactory-ref="mqConnectionFactory"
p:messageListener-ref="myMessageListener" p:sessionTransacted="true"
p:concurrentConsumers="1" p:maxConcurrentConsumers="20"
p:receiveTimeout="30000" p:idleTaskExecutionLimit="10"
p:idleConsumerLimit="5" />
如果有人想知道这里的不同参数是我在整个互联网上收集的:
The idleConsumerLimit property is used to specify the the maximum
number of consumers that are allowed to be idle at a given time.
Increasing this limit causes invokers to be created more aggressively.
This can be useful to ramp up the number of consumers faster.
idleTaskExecutionLimit: The limit for the number of allowed idle
executions of a receive task. The default is 1 causing idle resources
to be closed early once a task does not receive a message.
idleTaskExecutionLimit property is set to 10 to allow tasks to execute
10 times instead of the default value of 1.
receiveTimeout property is set to 30 seconds to tell the DMLC's
receive operation to poll for message for 30 seconds instead of the
default one second.
这是我的理解:
So this means: If there is a heavy load Spring JMS will start up to 20
consumers (maxConcurrentConsumers) and as soon as the load goes down, these consumers will
continue to read messages for 30 seconds (receiveTimeout) before closing or going idle.
So after that 5 consumers (idleConsumerLimit) will still idle for 10 seconds (?) (idleTaskExecutionLimit) before
closing down.
如有错误请指正
一个互联网页面说我的消费者每 30 秒只会阅读一条消息,但我认为这是对 "receiveTimeout" 的正确解释。
我们目前遇到的一个问题是,我们有很多 GET 从 MQ 读取,但实际上没有收到消息 - 就像我们可以有 60'000 个 GET 实际上能够读取消息,而 2'100 '000 GET 发生但未阅读消息。
感谢您帮助我更好地理解 Spring JMS 的行为。
在询问代理客户端是否还有更多工作时使用接收超时 (receive()
) - 它不是轮询代理,只是轮询客户端库以查看代理是否发送了更多消息。它与接收消息的频率无关。
当超时发生时,容器立即再次调用receive()
。
高接收超时意味着容器对 stop()
次调用的响应较慢 - 容器只能在 receive()
次调用之间停止。
我正在进入一个实现 IBM MQ 侦听 Spring JMS 应用程序的项目,但我无法理解 DefaultMessageListenerContainer 中的 "receiveTimeout"。
与来自互联网的资源相比,我认为我的项目有点特别,因为我们为 "receiveTimeout" 参数使用了非常高的 30 秒值,但我不知道这实际上意味着什么。
我已经弄明白了"receiveTimeout"参数的含义,下面我会在Spring配置后给大家说说我的理解。
仅供参考:我们 reading/processing 来自队列的许多消息都非常小(大约 100kb)。
这是我们正在使用的 spring 配置:
<bean id="msgListenerContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer"
p:connectionFactory-ref="mqConnectionFactory"
p:messageListener-ref="myMessageListener" p:sessionTransacted="true"
p:concurrentConsumers="1" p:maxConcurrentConsumers="20"
p:receiveTimeout="30000" p:idleTaskExecutionLimit="10"
p:idleConsumerLimit="5" />
如果有人想知道这里的不同参数是我在整个互联网上收集的:
The idleConsumerLimit property is used to specify the the maximum number of consumers that are allowed to be idle at a given time. Increasing this limit causes invokers to be created more aggressively. This can be useful to ramp up the number of consumers faster.
idleTaskExecutionLimit: The limit for the number of allowed idle executions of a receive task. The default is 1 causing idle resources to be closed early once a task does not receive a message. idleTaskExecutionLimit property is set to 10 to allow tasks to execute 10 times instead of the default value of 1.
receiveTimeout property is set to 30 seconds to tell the DMLC's receive operation to poll for message for 30 seconds instead of the default one second.
这是我的理解:
So this means: If there is a heavy load Spring JMS will start up to 20 consumers (maxConcurrentConsumers) and as soon as the load goes down, these consumers will continue to read messages for 30 seconds (receiveTimeout) before closing or going idle. So after that 5 consumers (idleConsumerLimit) will still idle for 10 seconds (?) (idleTaskExecutionLimit) before closing down.
如有错误请指正
一个互联网页面说我的消费者每 30 秒只会阅读一条消息,但我认为这是对 "receiveTimeout" 的正确解释。
我们目前遇到的一个问题是,我们有很多 GET 从 MQ 读取,但实际上没有收到消息 - 就像我们可以有 60'000 个 GET 实际上能够读取消息,而 2'100 '000 GET 发生但未阅读消息。
感谢您帮助我更好地理解 Spring JMS 的行为。
在询问代理客户端是否还有更多工作时使用接收超时 (receive()
) - 它不是轮询代理,只是轮询客户端库以查看代理是否发送了更多消息。它与接收消息的频率无关。
当超时发生时,容器立即再次调用receive()
。
高接收超时意味着容器对 stop()
次调用的响应较慢 - 容器只能在 receive()
次调用之间停止。