Auto-configure Rabbit MessageConverter

If a `MessageConverter` bean is available, we now associate it to the
created `RabbitTemplate` and `RabbitListenerContainerFactory`. That way,
registering a custom `MessageConverter` is all that's needed.

The Rabbit auto-configuration is now using the new `ObjectProvider` that
offers a nicer API to detect if a primary candidate is available for
optional collaborators.

Closes gh-5088
This commit is contained in:
Stephane Nicoll
2016-02-29 19:32:30 +01:00
parent 360caf3d97
commit 813d86e5e0
5 changed files with 67 additions and 5 deletions

View File

@@ -3734,7 +3734,8 @@ directly into your own beans:
----
NOTE: {spring-amqp-javadoc}/rabbit/core/RabbitMessagingTemplate.{dc-ext}[`RabbitMessagingTemplate`]
can be injected in a similar manner.
can be injected in a similar manner. If a `MessageConverter` bean is defined, it is associated
automatically to the auto-configured `AmqpTemplate`.
Any `org.springframework.amqp.core.Queue` that is defined as a bean will be automatically
used to declare a corresponding queue on the RabbitMQ instance if necessary.
@@ -3745,7 +3746,8 @@ used to declare a corresponding queue on the RabbitMQ instance if necessary.
==== 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.
has been defined, a default one is configured automatically. If a `MessageConverter`
beans is defined, is is associated automatically to the default factory.
The following component creates a listener endpoint on the `someQueue` queue: