gpt4 book ai didi

spring-jms - 高 Spring JMS DefaultMessageListenerContainer.receiveTimeout 参数是什么意思?

转载 作者:行者123 更新时间:2023-12-04 15:31:51 24 4
gpt4 key购买 nike

我正在进入一个实现 IBM MQ 监听 Spring JMS 应用程序的项目,但我无法理解 DefaultMessageListenerContainer 中的“receiveTimeout”。

与来自互联网的资源相比,我认为我的项目有点特别,因为我们对“receiveTimeout”参数使用了非常高的 30 秒值,我不知道这实际上意味着什么。

我试图弄清楚“receiveTimeout”参数的含义,我将在Spring配置后在下面给你我的理解。

仅供引用:我们正在从一个队列中读取/处理许多非常小的消息(大约 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”的正确解释。

我们目前遇到的一个问题是,我们从 MQ 读取了许多 GET,但实际上并没有收到消息 - 就像我们可以有 60'000 个 GET 实际能够读取一条消息,而发生的 2'100'000 个 GET但没有阅读消息。

我很感谢任何帮助更好地理解 Spring JMS 的行为。

最佳答案

当询问代理客户端是否有更多工作( receive() )时使用接收超时 - 它不轮询代理,只是轮询客户端库以查看代理是否发送了更多消息。它与接收消息的频率无关。

当超时发生时,容器立即调用 receive()再次。

较高的接收超时意味着容器对 stop() 的响应会变慢调用 - 容器只能在 receive() 之间停止调用。

关于spring-jms - 高 Spring JMS DefaultMessageListenerContainer.receiveTimeout 参数是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38746928/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com