Allow to define a custom MessageRecoverer

This commit improves `SimpleRabbitListenerContainerFactoryConfigurer` to
use a custom `MessageConverter`. If such a bean is present, it is used
for the default factory that is auto-configured.

Closes gh-8194
This commit is contained in:
Stephane Nicoll
2017-02-09 10:43:03 +01:00
parent b931f564e6
commit aa49468171
4 changed files with 63 additions and 13 deletions

View File

@@ -4635,8 +4635,9 @@ the broker connection is lost. Retries are disabled by default.
==== Receiving a message
When the Rabbit infrastructure is present, any bean can be annotated with
`@RabbitListener` to create a listener endpoint. If no `RabbitListenerContainerFactory`
has been defined, a default one is configured automatically. If a `MessageConverter`
beans is defined, it is associated automatically to the default factory.
has been defined, a default one is configured automatically. If a `MessageConverter` or
`MessageRecoverer` beans are defined, they are associated automatically to the default
factory.
The following component creates a listener endpoint on the `someQueue` queue:
@@ -4699,9 +4700,11 @@ Then you can use in any `@RabbitListener`-annotated method as follows:
}
----
You can enable retries to handle situations where your listener throws an exception.
When retries are exhausted, the message will be rejected and either dropped or routed to a
dead-letter exchange if the broker is configured so. Retries are disabled by default.
You can enable retries to handle situations where your listener throws an exception. By
default `RejectAndDontRequeueRecoverer` is used but you can define a `MessageRecoverer`
of your own. When retries are exhausted, the message will be rejected and either dropped
or routed to a dead-letter exchange if the broker is configured so. Retries are disabled
by default.
IMPORTANT: If retries are not enabled and the listener throws an exception, by default the
delivery will be retried indefinitely. You can modify this behavior in two ways; set the