|
68 | 68 |
|
69 | 69 | import reactor.core.publisher.Mono; |
70 | 70 | import reactor.core.publisher.MonoProcessor; |
| 71 | +import reactor.core.publisher.Sinks; |
71 | 72 |
|
72 | 73 | /** |
73 | 74 | * A convenient base class for connecting application code to |
|
82 | 83 | @IntegrationManagedResource |
83 | 84 | public abstract class MessagingGatewaySupport extends AbstractEndpoint |
84 | 85 | implements org.springframework.integration.support.management.TrackableComponent, |
85 | | - IntegrationInboundManagement, IntegrationPattern { |
| 86 | + IntegrationInboundManagement, IntegrationPattern { |
86 | 87 |
|
87 | 88 | private static final long DEFAULT_TIMEOUT = 1000L; |
88 | 89 |
|
@@ -648,7 +649,7 @@ private Mono<Message<?>> doSendAndReceiveMessageReactive(MessageChannel requestC |
648 | 649 |
|
649 | 650 | sendMessageForReactiveFlow(requestChannel, messageToSend); |
650 | 651 |
|
651 | | - return buildReplyMono(requestMessage, replyChan.replyMono, error, originalReplyChannelHeader, |
| 652 | + return buildReplyMono(requestMessage, replyChan.replyMono.asMono(), error, originalReplyChannelHeader, |
652 | 653 | originalErrorChannelHeader); |
653 | 654 | }) |
654 | 655 | .onErrorResume(t -> error ? Mono.error(t) : handleSendError(requestMessage, t)); |
@@ -886,21 +887,19 @@ public Message<?> toMessage(Object object, @Nullable Map<String, Object> headers |
886 | 887 |
|
887 | 888 | private static class MonoReplyChannel implements MessageChannel, ReactiveStreamsSubscribableChannel { |
888 | 889 |
|
889 | | - private final MonoProcessor<Message<?>> replyMono = MonoProcessor.create(); |
| 890 | + private final Sinks.One<Message<?>> replyMono = Sinks.one(); |
890 | 891 |
|
891 | 892 | MonoReplyChannel() { |
892 | 893 | } |
893 | 894 |
|
894 | 895 | @Override |
895 | 896 | public boolean send(Message<?> message, long timeout) { |
896 | | - this.replyMono.onNext(message); |
897 | | - this.replyMono.onComplete(); |
898 | | - return true; |
| 897 | + return Boolean.TRUE.equals(this.replyMono.emitValue(message).hasEmitted()); |
899 | 898 | } |
900 | 899 |
|
901 | 900 | @Override |
902 | 901 | public void subscribeTo(Publisher<? extends Message<?>> publisher) { |
903 | | - publisher.subscribe(this.replyMono); |
| 902 | + publisher.subscribe(MonoProcessor.fromSink(replyMono)); |
904 | 903 | } |
905 | 904 |
|
906 | 905 | } |
|
0 commit comments