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

倖福魔咒の 提交于 2019-12-07 20:17:37

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.

  • 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.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!