我有2个jms侦听器应用程序,一个应用程序使用DefaultMessageListenerContainer
,其他应用程序使用SimpleMessageListenerContainer
具有DefaultMessageListenerContainer
的应用程序可以在EMS代理故障转移上重新连接,这是日志
Setup of JMS message listener invoker failed for destination 'SOME.TOPIC.T' - trying to recover. Cause: Connection is closed
Could not refresh JMS Connection for destination 'SOME.TOPIC.T' - retrying using FixedBackOff{interval=5000, currentAttempts=0, maxAttempts=unlimited}. Cause: Failed to connect to any server at: tcp://localhost:8285,tcp://localhost:8286
Could not refresh JMS Connection for destination 'SOME.TOPIC.T' - retrying using FixedBackOff{interval=5000, currentAttempts=1, maxAttempts=unlimited}. Cause: Failed to connect to any server at: tcp://localhost:8285,tcp://localhost:8286
具有SimpleMessageListenerContainer
的应用程序无法在EMS代理故障转移上重新连接,这是日志
[TIBCO EMS TCPLink Reader (Server-109365)] INFO org.springframework.jms.listener.SimpleMessageListenerContainer - Trying to recover from JMS Connection exception: javax.jms.JMSException: Connection has been terminated
[TIBCO EMS TCPLink Reader (Server-109366)] ERROR org.springframework.jms.listener.SimpleMessageListenerContainer - Encountered non-recoverable JMSException
javax.jms.JMSException: Connection has been terminated
at com.tibco.tibjms.Tibjmsx.buildException(Tibjmsx.java:659) ~[tibjms-8.3.0.jar!/:?]
at com.tibco.tibjms.TibjmsConnection._invokeOnExceptionCallback(TibjmsConnection.java:2118) [tibjms-8.3.0.jar!/:?]
at com.tibco.tibjms.TibjmsConnection._onDisconnected(TibjmsConnection.java:2487) [tibjms-8.3.0.jar!/:?]
at com.tibco.tibjms.TibjmsConnection$ServerLinkEventHandler.onEventDisconnected(TibjmsConnection.java:367) [tibjms-8.3.0.jar!/:?]
at com.tibco.tibjms.TibjmsxLinkTcp$LinkReader.work(TibjmsxLinkTcp.java:328) [tibjms-8.3.0.jar!/:?]
at com.tibco.tibjms.TibjmsxLinkTcp$LinkReader.run(TibjmsxLinkTcp.java:259) [tibjms-8.3.0.jar!/:?]
两者都连接到相同的代理实例,如何使SimpleMessageListenerContainer
侦听器在JMS异常上重新连接?
答案 0 :(得分:1)
简单的容器是... er ...简单。
它仅尝试一次恢复连接。
默认容器更加复杂,并配置了BackOff
(对于无限尝试,每5秒默认一次)。
如果需要这种复杂性,请使用默认容器,但它必须具有事务性,以避免消息丢失的可能性-请参阅javadocs。