适配器连接到 jms 队列。我有一些逻辑需要在成功交付和故障转移时触发,因此我已将适配器连接到 ExpressionEvaluatingRequestHandlerAdvice。
<jms:outbound-channel-adapter id="101Out"
channel="101DestinationChannel"
connection-factory="101Factory"
destination-expression="headers.DESTINATION_NAME"
destination-resolver="namingDestinationResolver"
explicit-qos-enabled="true">
<jms:request-handler-advice-chain>
<beans:bean class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice">
<beans:property name="onSuccessExpression" ref="success"/>
<beans:property name="successChannel" ref="normalOpsReplicationChannel"/>
<beans:property name="onFailureExpression" ref="failure"/>
<beans:property name="failureChannel" ref="failoverInitiationChannel" />
</beans:bean>
<beans:bean id="retryAdvice" class="org.springframework.integration.handler.advice.RequestHandlerRetryAdvice">>
<beans:property name="retryTemplate" ref="retryTemplate"/>
</beans:bean>
</jms:request-handler-advice-chain>
</jms:outbound-channel-adapter>
现在这两种方法都可以正确触发,并且复制/故障转移逻辑可以正常执行。但是在失败时(当我停止队列管理器时),一旦连接到 failureChannel 的进程完成,我就会看到错误正在传播回调用源(在本例中为 HTTP 端点)。
该建议应该阻止错误传播,对吗?
<service-activator input-channel="failoverInitiationChannel"
ref="failoverInitiator" />
我有一个连接到 failureChannel 的服务激活器,它只会改变一个单例。我在这里所做的任何事情都不会触发该错误。此外,返回的错误肯定是针对队列访问的,因此它不可能是我在激活故障转移启动器后所做的任何操作。
org.springframework.jms.IllegalStateException: JMSWMQ0018: Failed to connect to queue manager 'APFDEV1' with connection mode 'Client' and host name 'localhost(1510)'.
我很困惑是否应该使用 RequestHandlerRetryAdvice 上的 recoveryCallback 或这个来实际停止错误。但即使成功,我也确实需要采取行动,因此 ExpressionEvaluatingAdvice 更适合我的场景。
感谢您提前提供的帮助:-)
最佳答案
这是默认行为。请参阅 ExpressionEvaluatingRequestHandlerAdvice
javadocs 了解 trapException
属性...
/**
* If true, any exception will be caught and null returned.
* Default false.
* @param trapException true to trap Exceptions.
*/
public void setTrapException(boolean trapException) {
this.trapException = trapException;
}
我会在引用手册中添加注释。
关于spring - 应用表达式评估请求处理程序建议是否会抑制错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33278621/