温馨提示:本文翻译自stackoverflow.com,查看原文请点击:其他 - spring integration dsl error handling and continue
spring-integration spring-integration-dsl

其他 - Spring Integration DSL错误处理并继续

发布于 2020-03-27 10:46:40

在我的Spring集成应用程序中,我具有执行errorChannel指定的Async网关方法。

错误时-我想通过将集成流注册到errorChannel来处理错误(我能够成功完成)。

处理并处理完错误后,有条件地我可能想发送到其他通道进行进一步处理,最后将其回复给网关。实现此目标的最佳方法是什么?

例子->

@MessagingGateway(errorChannel = "errorChannel")
public interface OrchestrationServicesGateway {
   @Gateway(requestChannel = "payment.input", replyChannel = 
   "payment.output")
   Future<JobData> processPayment(PaymentRequest request);
}

集成流程具有步骤A-> B-> C-> D->结束

现在,如果步骤B引发错误,我想处理一个通用函数,并基于一些规则,我们可能希望继续执行C或跳转到D / end。

我该如何实现?

查看更多

查看更多

提问者
basu76
被浏览
68
Artem Bilan 2019-07-03 21:53

我建议您看一下ExpressionEvaluatingRequestHandlerAdvicehttps : //docs.spring.io/spring-integration/docs/5.1.6.RELEASE/reference/html/#expression-advice将其添加到所有单个端点,并在failureChannel某些路由器逻辑上具有该位置,以确定进一步向何处发送补偿消息。

这样,您将没有一个具有硬逻辑即可确定消息失败位置的错误处理点。