diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlowDefinition.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlowDefinition.java index 0f6d9aa7ab..7a4c9600c6 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlowDefinition.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlowDefinition.java @@ -96,7 +96,7 @@ import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; -import reactor.core.publisher.TopicProcessor; +import reactor.core.publisher.EmitterProcessor; import reactor.util.function.Tuple2; /** @@ -2728,7 +2728,7 @@ public abstract class IntegrationFlowDefinition processor = TopicProcessor.share(false); + Processor processor = EmitterProcessor.create(false); publisher = (Publisher>) processor; Subscriber> subscriber = (Subscriber>) processor; addComponent(new ReactiveConsumer(channelForPublisher, subscriber)); diff --git a/spring-integration-core/src/test/java/org/springframework/integration/dsl/reactivestreams/ReactiveStreamsTests.java b/spring-integration-core/src/test/java/org/springframework/integration/dsl/reactivestreams/ReactiveStreamsTests.java index 76a3cf443a..02187b1899 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/dsl/reactivestreams/ReactiveStreamsTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/dsl/reactivestreams/ReactiveStreamsTests.java @@ -105,31 +105,35 @@ public class ReactiveStreamsTests { public void testPollableReactiveFlow() throws Exception { this.inputChannel.send(new GenericMessage<>("1,2,3,4,5")); - CountDownLatch warmUpLatch = new CountDownLatch(3); CountDownLatch latch = new CountDownLatch(6); Flux.from(this.pollablePublisher) + .take(6) .filter(m -> m.getHeaders().containsKey(IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER)) .doOnNext(p -> latch.countDown()) - .doOnNext(p -> warmUpLatch.countDown()) - .take(6) .subscribe(); - Future> future = - Executors.newSingleThreadExecutor().submit(() -> - Flux.just("11,12,13") - .map(v -> v.split(",")) - .flatMapIterable(Arrays::asList) - .map(Integer::parseInt) - .>map(GenericMessage::new) - .concatWith(this.pollablePublisher) - .map(Message::getPayload) - .take(7) - .log("org.springframework.integration.flux") - .collectList() - .block(Duration.ofSeconds(10))); + CountDownLatch secondSubscriberLatch = new CountDownLatch(1); - assertTrue(warmUpLatch.await(10, TimeUnit.SECONDS)); + Future> future = + Executors.newSingleThreadExecutor().submit(() -> { + Thread.sleep(100); + return Flux.just("11,12,13") + .map(v -> v.split(",")) + .flatMapIterable(Arrays::asList) + .map(Integer::parseInt) + .>map(GenericMessage::new) + .concatWith(this.pollablePublisher) + .take(7) + .map(Message::getPayload) + .log("org.springframework.integration.flux") + .collectList() + .doOnSubscribe(s -> secondSubscriberLatch.countDown()) + .block(Duration.ofSeconds(10)); + } + ); + + assertTrue(secondSubscriberLatch.await(10, TimeUnit.SECONDS)); this.inputChannel.send(new GenericMessage<>("6,7,8,9,10"));