【发布时间】:2018-01-02 12:52:02
【问题描述】:
我有一个这样的集成流程:
@Bean
public IntegrationFlow inboundRequestFlow()
{
return IntegrationFlows.from( inboundRequestGateway() )
.log( ... )
.filter( requestValidator,
spec -> spec.discardChannel( invalidRequestChannel() ) )
.bridge( spec -> spec.requiresReply( false ) )
.channel( asyncFlowChannel )
.wireTap(
//sends a NO_CONTENT reply if the request is ok
flow -> flow.enrichHeaders( spec -> spec.header( HttpHeaders.STATUS_CODE, HttpStatus.NO_CONTENT ).defaultOverwrite( true ) )
.transform( payload -> "" )
.channel( inboundGatewayReplyChannel() )
).get();
}
它在 http 网关上接收请求,对其进行验证,如果一切正常,则将请求发送到“asyncFlowChannel”并以 204 回复入站网关。
'asyncFlowChannel' 是另一个在 Executor 通道上运行的 IntegrationFlow 的起点:
@Bean
public IntegrationFlow outboundFlow()
{
return IntegrationFlows.from( asyncFlowChannel)
.log( ... )
.transform( ... )
.transform( ... )
.split(... )
.resequence( ... )
.enrichHeaders( ... )
.log( ... )
.transform( ... )
.handle( this.outboundSOAPGateway() )
.log( .. )
.handle( ... )
.bridge( spec -> spec.requiresReply( false ) )
.channel( anotherAsyncFlowChannel )
.get();
}
如果我的 outboundGateway 发生异常(由于网络相关的 IO 错误或错误响应),我想记录错误并采取适当的措施。但我无法在 outboundSOAPGateway 上设置错误通道,并且起始流程上的 inboundRequestGateway 已经收到它的回复。
我得到的错误的唯一线索是这个日志:
10:19:53.002 WARN [outbound-flow-0] org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel - 收到回复消息但接收线程已经收到回复:ErrorMessage [payload=..., headers =...]
我的问题是:在异步流中处理出站网关上的错误的正确方法是什么,其中启动流的 inboundGateway 已经收到它的回复?
【问题讨论】: