Cannot Connect (temporary queue server failure) prevents container start
We have just started using Spring AMQP / Rabbit MQ within our project and have run into a problem that I am hoping there is a known solution for.
We have a consumer application using a pretty by-the-book <rabbit:listener-container/> configuration, and all works well when it is working. What we have run into is if there is a problem contacting the queue server(s) on startup, the entire container startup is failed.
This can be simulated on a linux consumer box by either pointing the consumer at a non-existant IP address, or using iptables to drop the outgoing request packets:
iptables -A OUTPUT -p tcp --destination-port 5672 -j DROP
- the problem is this means a transient connection issue during startup could cause complete startup failure.
I have looked through the code, and it is clear that it is coded just this way.. in
org.springframework.amqp.rabbit.listener.SimpleMes sageListenerContainer.AsyncMessageProcessingConsum er.getStartupException()
an exception is blindly thrown if the initialization does not complete by a timeout.
Our expectation would be that unable to connect should just retry, just as bad password or rejected connections do.
Any work around or potential solution short of writing a custom MessageListenerContainer?