Spring amqp 弹簧兔-信号灯许可证泄漏导致;没有可用的频道“;例外

Spring amqp 弹簧兔-信号灯许可证泄漏导致;没有可用的频道“;例外,spring-amqp,spring-rabbit,Spring Amqp,Spring Rabbit,我们为消费者使用CachingConnectionFactory。每次连接断开,我都会看到一个checkoutPermit被获取,但从未发布过。所以,假设我们使用默认缓存通道大小25,下次,当连接在删除后恢复时,可用的许可数量将是24。一段时间后,导致许可数量为0,因此导致异常AmqpTimeoutException(“无可用通道”) 我在版本1.6.10-RELEASE、1.7.3-RELEASE和2.0.0-BUILD-SNAPSHOT中观察到了这种行为 我们是否有可能以错误的方式使用了库,

我们为消费者使用CachingConnectionFactory。每次连接断开,我都会看到一个checkoutPermit被获取,但从未发布过。所以,假设我们使用默认缓存通道大小25,下次,当连接在删除后恢复时,可用的许可数量将是24。一段时间后,导致许可数量为0,因此导致异常AmqpTimeoutException(“无可用通道”)

我在版本1.6.10-RELEASE、1.7.3-RELEASE和2.0.0-BUILD-SNAPSHOT中观察到了这种行为

我们是否有可能以错误的方式使用了库,并且我们应该注意手动释放checkoutPermit,可能是通过关闭自己的通道?(断开连接后,永远不会调用ReleasePermitifRequired)

提前谢谢


示例(使用1.7.3-RELEASE) 配置 处理程序(仅用于测试) 我使用代理在RabbitMQ和我的应用程序之间测试连接断开,在这里我手动断开与RabbitMQ的连接。

已确认

那绝对是臭虫。当我们失去联系时,我们也失去了所有的频道。因此,我们必须重新设置相关许可证

请出示一张描述正确的票

同时,我想作为一种解决方法,您不应该使用
etChannelCheckoutTimeout(1200)
,而将其保留为
0
,默认值是什么:

/**
 * Sets the channel checkout timeout. When greater than 0, enables channel limiting
 * in that the {@link #channelCacheSize} becomes the total number of available channels per
 * connection rather than a simple cache size. Note that changing the {@link #channelCacheSize}
 * does not affect the limit on existing connection(s), invoke {@link #destroy()} to cause a
 * new connection to be created with the new limit.
 * <p>
 * Since 1.5.5, also applies to getting a connection when the cache mode is CONNECTION.
 * @param channelCheckoutTimeout the timeout in milliseconds; default 0 (channel limiting not enabled).
 * @since 1.4.2
 * @see #setConnectionLimit(int)
 */
public void setChannelCheckoutTimeout(long channelCheckoutTimeout) {
/**
*设置通道签出超时。大于0时,启用通道限制
*在这种情况下,{@link#channelCacheSize}将成为每个节点的可用通道总数
*连接,而不是简单的缓存大小。请注意,更改{@link#channelCacheSize}
*不影响对现有连接的限制,调用{@link#destroy()}以导致
*要使用新限制创建的新连接。
*
*从1.5.5开始,也适用于在缓存模式为连接时获取连接。
*@param channelCheckoutTimeout超时以毫秒为单位;默认值0(未启用通道限制)。
*@自1.4.2起
*@see#setConnectionLimit(int)
*/
公共无效设置channelCheckoutTimeout(长channelCheckoutTimeout){

如果你能拿出测试用例让我们来解决这个问题,那就太好了。谢谢,我目前正在处理这个问题,试图隔离这个部分,而不是使用生产代码。完成后,我会告诉你,也许我会在代码中发现一个错误配置。我附上了一个示例,其中我尝试从生产中模拟配置应用程序。此示例成功复制了我描述的相同行为。我在复制此错误时遇到问题-侦听器检测到关闭并释放其许可证。请参阅我对JIRA问题的评论。
public class TestHandler {

    public String handleMessage(byte[] textBytes) {
        String text = new String(textBytes);
        System.out.println("Received: " + text);
        return text;
    }

}
/**
 * Sets the channel checkout timeout. When greater than 0, enables channel limiting
 * in that the {@link #channelCacheSize} becomes the total number of available channels per
 * connection rather than a simple cache size. Note that changing the {@link #channelCacheSize}
 * does not affect the limit on existing connection(s), invoke {@link #destroy()} to cause a
 * new connection to be created with the new limit.
 * <p>
 * Since 1.5.5, also applies to getting a connection when the cache mode is CONNECTION.
 * @param channelCheckoutTimeout the timeout in milliseconds; default 0 (channel limiting not enabled).
 * @since 1.4.2
 * @see #setConnectionLimit(int)
 */
public void setChannelCheckoutTimeout(long channelCheckoutTimeout) {