Spring integration Spring集成Java DSL入站和出站错误处理
我正在尝试构建一个集成解决方案,其中Spring integration Spring集成Java DSL入站和出站错误处理,spring-integration,spring-integration-dsl,spring-integration-http,Spring Integration,Spring Integration Dsl,Spring Integration Http,我正在尝试构建一个集成解决方案,其中 IntegrationFlows .from(inBoundGateway) .enrichHeaders(enrichHeaders()) .transform(dto to externaldto) .handle(outBoundGateway, advice -> advice.advice(retryAdvice())) .transform(exetrnaldto to dto) .get() @Bean
IntegrationFlows
.from(inBoundGateway)
.enrichHeaders(enrichHeaders())
.transform(dto to externaldto)
.handle(outBoundGateway, advice -> advice.advice(retryAdvice()))
.transform(exetrnaldto to dto)
.get()
@Bean
RequestHandlerRetryAdvice rhra
rhra.setRecoveryCalBack(errorMessgaeRecoverer());
@Bean
ErrorMessageSendingRecoverer errorMessgaeRecoverer
我的outboundgateway定义为
Http.outboundGateway(uri, resttemplate)
...
.get()
new RestTemplate(requestFactory)
工厂在哪里
TrustStratgey ts = new TrustStratgey(){
public boolean isTrusted(...){
return true;
}
}
SSLContext context = SSLContexts,custom().loaddTrustMaterials(null, ts);
SSLContextFactory cf = new SSLContextFactory(context, new NoopHostnameVerifier());
HttpClientBuilder clientBuilder ..
clientBuilder.setSSLSocketFactory()
快乐之路运行良好,我面临的问题是不太快乐之路
- 当Api调用返回错误响应时。转换(exetrnaldto到dto)失败,客户端获得500
- 我想将错误resposne json也转换为我的json
- 如何处理错误情况
希望能看到这篇文章,找不到任何答案,我浏览了很多书籍和论坛,感觉Java DSL还没有被广泛使用或评论。你的问题中没有任何特定于Spring集成Java DSL的内容。 它实际上更多的是关于如何处理服务器端(MVC-HttpInboundGateway)和客户端上的HTTP错误--
RestTemplate
和HttpOutboundGateway。
JavaDSL只是对现有技术和解决方案的一种补充
因此,@Controller Advice@ErrorHandler
是一个MVC服务器端。您当然可以让它与HttpInboundGateway一起工作,但对于客户端REST调用来说,这确实是一个错误的方向
看起来您希望捕获该.handle(outBoundGateway)
的REST错误调用。考虑使用<代码>表达式来评估ReQuththand Lead建议与该<代码> ReqyObjiT/<代码>。因此,您将能够使用它的failureChannel
处理异常并将其分别转换为所需的JSON
请参阅文档中的更多内容: