我有三个不同的系统。我正在使用Spring集成来同步所有这些系统中的数据。弹簧集成中的错误处理
系统1通话--->系统2通过http:入站网关
<int-http:inbound-gateway id="gateway"
path="/save" supported-methods="POST, PUT"
request-channel="requestChannel" reply-channel="replyChannel"
request-payload-type="com.model.Request"
mapped-request-headers="source" error-channel="errorChannel" />
系统2将调用服务方法来存储返回的响应数据,如果请求是有效的别的抛出异常
<int:service-activator ref="serviceMethod"
method="saveIfValid" input-channel="requestChannel"
output-channel="serviceOutput" />
<int:recipient-list-router id="id1"
input-channel="serviceOutput">
<int:recipient channel="system1" />
<int:recipient channel="system3" />
</int:recipient-list-router>
只有在操作成功的情况下,我才需要向系统1和系统3发送服务方法响应。 调用服务方法后,根据服务方法响应,使用变压器生成系统3的请求。在变压器之后,我将请求置于mq队列中。
<int:transformer id="transformer1"
method="convert" input-channel="system3"
output-channel="jmsInput">
<bean
class="com.transformer.System3Transformer" />
</int:transformer>
<int-jms:outbound-channel-adapter id="adapter"
channel="jmsInput" destination-name="queueName">
</int-jms:outbound-channel-adapter>
更新JMS出站代码
<int-jms:outbound-channel-adapter id="jms1"
\t \t channel="jmsIn" destination-name="queueName">
\t \t <int-jms:request-handler-advice-chain>
\t \t \t <bean
\t \t \t \t class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice">
\t \t \t \t <property name="onSuccessExpression" value="T(Boolean).TRUE" />
\t \t \t \t <property name="successChannelName" value="afterSuccessDeleteChannel" />
\t \t \t <property name="onFailureExpression" value="T(Boolean).FALSE" />
\t \t \t \t <property name="failureChannelName" value="afterFailRenameChannel" />
\t \t \t </bean>
\t \t </int-jms:request-handler-advice-chain>
\t </int-jms:outbound-channel-adapter>
我的问题是
- 如果服务类失败我需要发送错误响应,并停止了流动
- 一世f服务方法成功保存数据,但转换失败,系统1应该获得成功响应并记录错误。
- 在这里,因为我在出站适配器中使用错误通道,即使变压器出现错误,它也会返回到系统1.
- 请建议如何处理错误而不使用全局错误通道以及如何处理出站jms中的错误适配器。
- 感谢你回答我的quesion
谢谢你回答我的问题。如果在中发生任何错误,我只是想将它记录下来,我不想向系统1显示错误。你能否帮助实现这一点? –
' \t \t \t \t <属性名=” onSuccessExpression”值= “有效载荷”/> \t \t \t \t <属性名= “successChannelName” 值= “afterSuccessDeleteChannel”/> \t \t \t \t <属性名= “onFailureExpression” 值= “有效载荷”/> \t \t \t \t <属性名= “failureChannelName” 值= “afterFailRenameChannel”/> \t \t \t ' –
请参阅上面的代码。它既涉及成功渠道,也涉及失败渠道。你能解释一下它是如何评估它是成功还是失败? 。 –