gpt4 book ai didi

java - RabbitMQ com.rabbitmq.client.AlreadyClosedException : connection is already closed due to connection error

转载 作者:搜寻专家 更新时间:2023-11-01 03:48:34 29 4
gpt4 key购买 nike

我正在使用 rabbitmq 作为代理,在我的不同应用程序之间分派(dispatch)请求和响应。当我面对 rabbitmq 的奇怪行为时。它在处理 2500 到 3000 条记录后给了我这个异常。

com.rabbitmq.client.AlreadyClosedException: connection is already closed due to connection error; cause: java.net.SocketException: Connection reset at com.rabbitmq.client.impl.AMQChannel.ensureIsOpen(AMQChannel.java:195) ~[amqp-client-3.5.6.jar:na] at com.rabbitmq.client.impl.AMQChannel.transmit(AMQChannel.java:309) ~[amqp-client-3.5.6.jar:na]

当我尝试在消息之间2 秒延迟 运行我的客户端时,还有一件事确实发生了这个问题。这是我尝试发布消息的代码。

     try {
byte[] e = jsonMessage.getBytes(RabbitConf.COMMUNICATION_ENCODING);
this.channel.basicPublish(exchangeType.name(), rountingKey.name(), (BasicProperties)null, e);
} catch (IOException var6) {
this.LOG.error("IOException when sending data to rabbit:", var6);
}

我正在为我的客户端使用 amqp-client 3.6.0。欢迎提出任何建议。

最佳答案

您可以尝试使用 qos 值(尽管从文档中不清楚这是否对发布 端有影响):

this.channel.basicQos(1);

参见:http://www.rabbitmq.com/releases/rabbitmq-java-client/current-javadoc/com/rabbitmq/client/Channel.html#basicQos-int- .

关于java - RabbitMQ com.rabbitmq.client.AlreadyClosedException : connection is already closed due to connection error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35575331/

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