GH-3276: reactive inbound: Fix onErrorResume

Fixes https://github.com/spring-projects/spring-integration/issues/3276

The `onErrorResume` for the `MessagingGatewaySupport.doSendAndReceiveMessageReactive()`
was in wrong place: only for the `buildReplyMono` which works only
when an outbound flow is fully based on reactive channels.
With a regular direct channel we can get an exception from the
`sendMessageForReactiveFlow` which is not covered with the mentioned
`onErrorResume` for the error handling on the configured `errorChannel`

Cherry-pick to `5.2.x & 5.1.x`
This commit is contained in:
Artem Bilan
2020-05-13 14:13:40 -04:00
committed by Gary Russell
parent 7cfab7b9a8
commit 619c5bfa13

View File

@@ -636,7 +636,8 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
sendMessageForReactiveFlow(requestChannel, requestMessage);
return buildReplyMono(requestMessage, replyChan.replyMono, error, originalReplyChannelHeader,
originalErrorChannelHeader);
originalErrorChannelHeader)
.onErrorResume(t -> error ? Mono.error(t) : handleSendError(requestMessage, t));
});
}
@@ -686,8 +687,7 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
.setHeader(MessageHeaders.ERROR_CHANNEL, originalErrorChannelHeader)
.build();
}
})
.onErrorResume(t -> error ? Mono.error(t) : handleSendError(requestMessage, t));
});
}
private Mono<Message<?>> handleSendError(Message<?> requestMessage, Throwable exception) {