Automatic retry connection to broker by spring-rabbitmq

user6023611 picture user6023611 · Mar 23, 2017 · Viewed 10.3k times · Source

I have read this fragment of docs:

RabbitMQ Automatic Connection/Topology recovery

Since the first version of Spring AMQP, the framework has provided its own connection and channel recovery in the event of a broker failure. Also, as discussed in Section 3.1.10, “Configuring the broker”, the RabbitAdmin will re-declare any infrastructure beans (queues etc) when the connection is re-established. It therefore does not rely on the Auto Recovery that is now provided by the amqp-client library. Spring AMQP now uses the 4.0.x version of amqp-client, which has auto recovery enabled by default. Spring AMQP can still use its own recovery mechanisms if you wish, disabling it in the client, (by setting the automaticRecoveryEnabled property on the underlying RabbitMQ connectionFactory to false). However, the framework is completely compatible with auto recovery being enabled. This means any consumers you create within your code (perhaps via RabbitTemplate.execute()) can be recovered automatically.

I am not sure If I correctly understand. In my application.properties I have defined port and host. During starting my spring-boot app it successfully established connection and all necessary beans to communicate with queue.

However, what in case when during start my app broker is shutdown and it will be launched five minutes after starting of app ? Does spring-rabbitmq manage to reconnect and define all beans ?

Answer

Artem Bilan picture Artem Bilan · Mar 23, 2017

That's correct. Spring AMQP manages the re-connection and recovery automatically.

This subject isn't related to bean definitions. If you talk about Broker entities declaration, then yes, that are processed really on the connection establishing.