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

I use rabbitmq as a broker to send a request and response between my various applications. For now, I come across strange behavior with a rabbit. This gives me this exception after processing from 2500 to 3000 records.

com.rabbitmq.client.AlreadyClosedException: the connection is already closed due to a connection error; Reason: java.net.SocketException: Connection reset when com.rabbitmq.client.impl.AMQChannel.ensureIsOpen (AMQChannel.java:195) ~ [amqp-client-3.5.6.jar: na] in com.rabbitmq.client. impl.AMQChannel.transmit (AMQChannel.java:309) ~ [AMQP client-3.5.6.jar: on]

Another thing, when I tried to start it with a client with a 2 second delay between messages, this problem arose. This is the code I'm trying to publish.

     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);
       }

I am using amqp-client 3.6.0 for my client. Any suggestion would be welcome.

+4
source share
1 answer

You can try playing with the value qos(although it is not clear from the docs whether this affects the publication side):

this.channel.basicQos(1);

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

0
source

Source: https://habr.com/ru/post/1630048/


All Articles