From 4e7caed9799cf79ed43b0d645cba1e444f78b9ff Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Wed, 3 Jul 2024 12:42:10 -0400 Subject: [PATCH] Add comment why and how we handle Mono->CompletableFuture --- .../handler/AbstractMessageProducingHandler.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractMessageProducingHandler.java b/spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractMessageProducingHandler.java index 5838ad7f9f..3d6d3a6e45 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractMessageProducingHandler.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/handler/AbstractMessageProducingHandler.java @@ -384,7 +384,14 @@ public abstract class AbstractMessageProducingHandler extends AbstractMessageHan reactiveReply .publishOn(Schedulers.boundedElastic()) - // TODO until Reactor supports context propagation from the MonoToCompletableFuture + /* + The MonoToCompletableFuture in Project Reactor does not support context propagation, + and it does not suppose to, since there is no guarantee how this Future is going to + be handled downstream. + However, in our case we process it directly in this class in the doProduceOutput() + via whenComplete() callback. So, when value is set into the Future, it is available + in the callback in the same thread immediately. + */ .doOnEach((signal) -> { try (AutoCloseable scope = IntegrationReactiveUtils .setThreadLocalsFromReactorContext(signal.getContextView())) {