【发布时间】:2016-01-21 14:09:35
【问题描述】:
适配器连接到 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 更适合我的场景。
提前感谢您的帮助:-)
【问题讨论】:
标签: spring jms spring-integration aop