Fix ReactiveStreamsConsumer for error handling
To support `onErrorContinue()` logic for the plain `Subscriber` we need to wrap its `onNext()` into a `try..catch` and respective `errorHandler` in the `ReactiveStreamsConsumer`
This commit is contained in:
@@ -166,21 +166,25 @@ public class ReactiveStreamsConsumer extends AbstractEndpoint implements Integra
|
||||
this.subscription =
|
||||
Flux.from(this.publisher)
|
||||
.flatMap(this.reactiveMessageHandler::handleMessage)
|
||||
.onErrorContinue(this::onError)
|
||||
.onErrorContinue((ex, data) -> this.errorHandler.handleError(ex))
|
||||
.subscribe();
|
||||
}
|
||||
else if (this.subscriber != null) {
|
||||
Flux.from(this.publisher)
|
||||
.doOnSubscribe((subs) -> this.subscription = subs::cancel)
|
||||
.onErrorContinue(this::onError)
|
||||
.subscribe(this.subscriber);
|
||||
this.subscription =
|
||||
Flux.from(this.publisher)
|
||||
.doOnComplete(this.subscriber::onComplete)
|
||||
.doOnSubscribe(this.subscriber::onSubscribe)
|
||||
.subscribe((data) -> {
|
||||
try {
|
||||
this.subscriber.onNext(data);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
this.errorHandler.handleError(ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void onError(Throwable ex, Object data) {
|
||||
this.errorHandler.handleError(ex);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStop() {
|
||||
if (this.subscription != null) {
|
||||
|
||||
Reference in New Issue
Block a user