|
1 | 1 | /* |
2 | | - * Copyright 2015-2024 the original author or authors. |
| 2 | + * Copyright 2015-2025 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
@@ -86,15 +86,21 @@ private boolean tryEmitMessage(Message<?> message) { |
86 | 86 | .setHeader(IntegrationMessageHeaderAccessor.REACTOR_CONTEXT, contextView) |
87 | 87 | .build(); |
88 | 88 | } |
89 | | - return switch (this.sink.tryEmitNext(messageToEmit)) { |
90 | | - case OK -> true; |
91 | | - case FAIL_NON_SERIALIZED, FAIL_OVERFLOW -> false; |
92 | | - case FAIL_ZERO_SUBSCRIBER -> |
93 | | - throw new IllegalStateException("The [" + this + "] doesn't have subscribers to accept messages"); |
94 | | - case FAIL_TERMINATED, FAIL_CANCELLED -> |
95 | | - throw new IllegalStateException("Cannot emit messages into the cancelled or terminated sink: " |
96 | | - + this.sink); |
97 | | - }; |
| 89 | + |
| 90 | + if (this.active) { |
| 91 | + return switch (this.sink.tryEmitNext(messageToEmit)) { |
| 92 | + case OK -> true; |
| 93 | + case FAIL_NON_SERIALIZED, FAIL_OVERFLOW -> false; |
| 94 | + case FAIL_ZERO_SUBSCRIBER -> |
| 95 | + throw new IllegalStateException("The [" + this + "] doesn't have subscribers to accept messages"); |
| 96 | + case FAIL_TERMINATED, FAIL_CANCELLED -> |
| 97 | + throw new IllegalStateException("Cannot emit messages into the cancelled or terminated sink: " |
| 98 | + + this.sink); |
| 99 | + }; |
| 100 | + } |
| 101 | + else { |
| 102 | + return false; |
| 103 | + } |
98 | 104 | } |
99 | 105 |
|
100 | 106 | @Override |
@@ -171,7 +177,7 @@ private void sendReactiveMessage(Message<?> message) { |
171 | 177 | public void destroy() { |
172 | 178 | this.active = false; |
173 | 179 | this.upstreamSubscriptions.dispose(); |
174 | | - this.sink.emitComplete(Sinks.EmitFailureHandler.FAIL_FAST); |
| 180 | + this.sink.emitComplete(Sinks.EmitFailureHandler.busyLooping(Duration.ofSeconds(1))); |
175 | 181 | super.destroy(); |
176 | 182 | } |
177 | 183 |
|
|
0 commit comments