java – ActiveMQConnectionFactory sendTimeout

根据ActiveMQ站点上的
this config page,connection.sendTimeout属性是:

Time to wait on Message Sends for a Response, default value of zero indicates to wait forever. Waiting forever allows the broker to have flow control over messages coming from this client if it is a fast producer or there is no consumer such that the broker would run out of memory if it did not slow down the producer. Does not affect Stomp clients as the sends are ack’d by the broker. (Since ActiveMQ-CPP 2.2.1)

我很难解释这意味着什么(以及sendTimeout属性到底是什么/它做了什么):

>什么是“消息发送”对象?
>为什么ActiveMQ会等待回复?它不是在JMS连接的服务器端吗?它不应该等待请求吗?
>它实际超时了什么?什么时候应该使用?

提前致谢!

最佳答案 超时会影响客户端向Broker发送消息.在发送不是异步的情况下,客户端等待Broker返回指示消息已被接收并添加到消息存储的响应.在某些情况下,如果经纪人已经参与了生产者流量控制,这可能会长时间阻塞,因为已达到其预设的内存限制之一.如果客户端应用程序无法容忍长时间等待发送,则可以配置此超时,以便MessageProducer :: send不会无限期阻塞.

消息以同步模式发送,因为Connection配置了alwaysSyncSend = true,或者因为MessageProducer正在发送并且传递模式设置为Persistent.

通常,如果您已将Broker配置为与您的用例匹配的限制,则不应使用此设置.

点赞