On the consuming side there is no way to configure that - the container will simply retry the connection on a fixed schedule; configurable by setting recoveryInterval
in the SimpleMessageListenerContainer
which defaults to 5 seconds. There's not much value in configuring a backoff for consumers.
On the publishing side, you can use spring-aop
to wrap the RabbitTemplate (AmqpTemplate interface) in a MethodInterceptor
that wraps the send*()
calls in a RetryTemplate
from spring-retry. The RetryTemplate
can be configured with all sorts of options, including backoff policy etc.
If you need help with that, I can try to find some time to post a Gist.
EDIT:
Per the comment below - correct, the recoveryInterval
is currently not available with the namespace (but you can still define the container as a <bean ... class="...SimpleMessageListenerContainer...>
.
However, it was added a few weeks ago to the master branch (commit here). It is available in the 1.3.0.BUILD-SNAPSHOT.
Also, as a result of your question here, I have added a RetryTemplate
option to the RabbitTemplate
(pull request here). It should be merged soon. The release candidate for 1.3.0 (1.3.0.RC1) is due Friday and the 1.3.0 GA release will follow within a couple of weeks.