user3221681
user3221681

Reputation: 23

Notifying channel shutdown to classes implementing the org.springframework.amqp.rabbit.connection.ConnectionListener

always returns true as the connection is auto recovering. Because of which the Health API does not learn of the connection failure for 10 mins after the connection has died.

Any other thoughts?

Upvotes: 1

Views: 773

Answers (2)

user3221681
user3221681

Reputation: 23

  • As suggested ,removing the native client's autorecovery mechanism did the trick for us.
  • Now the Spring AMQP auto recovery kicks in case of connection resets.
  • And the isOpen() method of the ConnectionListener returns the correct state of the connection each time so the health status API is also fixed.

Upvotes: 0

Gary Russell
Gary Russell

Reputation: 174729

First of all, autoRecovery is not necessary with Spring AMQP; it has always had its own recovery mechanism, which predates (by a very long time) the mechanism now provided by the client library.

It is effectively disabled on the consumer side anyway.

The reason being that when the broker recovers the channel, the code that was listening on that channel is long gone and the consumer is orphaned. To avoid this issue, we close the channel when the exception is detected to prevent autorecovery from recovering the channel.

So, the simple answer is to disable auto recovery in the underlying connection.

When using the SimpleMessageListenerContainer, it will continue to attempt reconnection indefinitely, based on its recoveryInterval or recoveryBackOff.

You can still use heartbeats.

In addition, the container publishes application events when a consumer encounters an exception; you can use an ApplicationListener to be notified of those events; see the documentation for more information.

Upvotes: 1

Related Questions