From 89e09afa745ea785982dac7c85b3d9e35873afec Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Tue, 29 Jun 2021 12:00:24 +0200 Subject: [PATCH] GH-2151 Document ProducerMessageHandlerCustomizer Resolves #2151 --- .../main/asciidoc/spring-cloud-stream.adoc | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/docs/src/main/asciidoc/spring-cloud-stream.adoc b/docs/src/main/asciidoc/spring-cloud-stream.adoc index 8152f00b7..c1099a00b 100644 --- a/docs/src/main/asciidoc/spring-cloud-stream.adoc +++ b/docs/src/main/asciidoc/spring-cloud-stream.adoc @@ -2454,6 +2454,35 @@ When set to true, if the binder supports asynchroous send results, send failures + Default: false. + +==== Advanced Producer Configuration + +In some cases Producer Properties are not enough to properly configure a producing MessageHandler in the binder, or may be you prefer a programmatic approach +while configuring such producing MessageHandler. Regardless of the reason, spring-cloud-stream provides `ProducerMessageHandlerCustomizer` to accomplish it. + + +==== +[source, java] +---- +@FunctionalInterface +public interface ProducerMessageHandlerCustomizer { + + /** + * Configure a {@link MessageHandler} that is being created by the binder for the + * provided destination name. + * @param handler the {@link MessageHandler} from the binder. + * @param destinationName the bound destination name. + */ + void configure(H handler, String destinationName); + +} +---- + +As you can see it gives you access to an actual instance of producing` MessageHandler` which you can configure as you wish. +All you need to do is provide implementation of this strategy and configure it as a `@Bean`. + +==== + [[content-type-management]] == Content Type Negotiation