jhalterman / lyra

High availability RabbitMQ client
Apache License 2.0
262 stars 74 forks source link

Recovery of the connection in RabbitMQ for Clustered environment #59

Closed mmuttharasan closed 7 years ago

mmuttharasan commented 8 years ago

I'm trying to recover the connection in RMQ for Clustered environment but unfortunately i'm not able to recover it in my code and also its not catching in exception..

For example. Initially node 1 is connected and i`m able to handle the messages. To test fail-over, we brought node 2 up and stopped node 1.. connections are being lost which is expected, but retry is not happening. When i restart my service, i'm able to get exception as "Rabbit MQ Message Exception : Error = 'connection is already closed due to connection error; cause: java.net.SocketException: Connection reset'"

Can anyone please suggest how to recover it in such case?

Have used below configurations in my code. (AMQP client) factory.setAutomaticRecoveryEnabled(true); factory.setNetworkRecoveryInterval(5000); factory.setTopologyRecoveryEnabled(true); factory.setRequestedHeartbeat(60);

By using Lyra connection recovery will occur with following config
.withRetryPolicy(new RetryPolicy() .withMaxAttempts(30) .withInterval(Duration.seconds(1)) .withMaxDuration(Duration.minutes(5)));

Please understand that this is not a client issue: for some reason, TCP connection to RabbitMQ is reset. It can be due to a variety of reasons but the primary suspects are:

michaelklishin commented 7 years ago

Lyra and RabbitMQ Java client's automatic recovery cannot be used together. As of #82 Lyra will forcefully disable Java client's recovery.

There isn't enough evidence of an issue in Lyra here => closing.