Reputation: 1594
I am using org.springframework.amqp.rabbit.connection.CachingConnectionFactory
to connect to RabbitMQ.
But my application is not automatically reconnect to rabbit server after disconnect (because of network problem)
Is there any configuration to make CachingConnectionFactory
auto reconnect?
Upvotes: 0
Views: 1485
Reputation: 121552
Consider to use setRequestedHeartBeat()
(requested-heartbeat
) on that object.
According to the RabbitMQ Manual:
In some types of network failure, packet loss can mean that disrupted TCP connections take some time to be detected by the operating system. AMQP offers a heartbeat feature to ensure that the application layer promptly finds out about disrupted connections (and also completely unresponsive peers). Heartbeats also defend against certain network equipment which may terminate "idle" TCP connections. In RabbitMQ versions 3.0 and higher, the broker will attempt to negotiate heartbeats by default (although the client can still veto them). Using earlier versions the client must be configured to request heartbeats.
Upvotes: 2