GH-9538: Rely on the customizeMonoReply() for thread switching
Fixes: https://github.com/spring-projects/spring-integration/issues/9538 Some applications might not be satisfied with `.publishOn(Schedulers.boundedElastic())` used by default for `Mono` replies. * Remove that `.publishOn(Schedulers.boundedElastic())` from the `AbstractMessageProducingHandler`. Instead, the target project is free to make a choice via `customizeMonoReply()`, e.g.: ``` .handle(RSockets.outboundGateway("/lowercase") .clientRSocketConnector(this.clientRSocketConnector), endpoint -> endpoint.customizeMonoReply((message, mono) -> mono.publishOn(Schedulers.boundedElastic()))) ```
This commit is contained in:
@@ -33,7 +33,6 @@ import org.reactivestreams.Publisher;
|
||||
import reactor.core.Exceptions;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.core.scheduler.Schedulers;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
@@ -386,7 +385,6 @@ public abstract class AbstractMessageProducingHandler extends AbstractMessageHan
|
||||
CompletableFuture<Object> replyFuture = new CompletableFuture<>();
|
||||
|
||||
reactiveReply
|
||||
.publishOn(Schedulers.boundedElastic())
|
||||
/*
|
||||
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
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.function.Function;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.scheduler.Schedulers;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -42,7 +43,6 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 5.2
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
@@ -86,7 +86,9 @@ public class RSocketDslTests {
|
||||
IntegrationFlow flow =
|
||||
f -> f
|
||||
.handle(RSockets.outboundGateway("/lowercase")
|
||||
.clientRSocketConnector(this.clientRSocketConnector))
|
||||
.clientRSocketConnector(this.clientRSocketConnector),
|
||||
endpoint -> endpoint.customizeMonoReply((message, mono) ->
|
||||
mono.publishOn(Schedulers.boundedElastic())))
|
||||
.transform("{ firstResult: payload }")
|
||||
.enrich(e -> e
|
||||
.requestPayloadExpression("payload.firstResult")
|
||||
|
||||
Reference in New Issue
Block a user