1

在将 Spring JMS 中的 DefaultMessageListenerContainer 与 TIBCO 队列一起使用时,我遇到了一个问题。当我将一条相对较小的消息放入队列时,队列中的侦听器需要几秒钟来读取消息并完成处理,并且一切顺利。另一方面,当我将一个可能需要更长的时间才能被业务层处理的请求放入队列时,在处理开始几分钟后,我得到了以下异常。

04:38:14.392 [TIBCO EMS TCPLink Reader (Server-34171)] WARN  o.s.j.c.CachingConnectionFactory - Encountered a JMSException - resetting the underlying JMS Connection
javax.jms.JMSException: Connection has been terminated
        at com.tibco.tibjms.Tibjmsx.buildException(Tibjmsx.java:509) ~[tibjms.jar:6.3.0]
        at com.tibco.tibjms.TibjmsConnection._invokeOnExceptionCallback(TibjmsConnection.java:2025) [tibjms.jar:6.3.0]
        at com.tibco.tibjms.TibjmsConnection._onDisconnected(TibjmsConnection.java:2394) [tibjms.jar:6.3.0]
        at com.tibco.tibjms.TibjmsConnection$ServerLinkEventHandler.onEventDisconnected(TibjmsConnection.java:349) [tibjms.jar:6.3.0]
        at com.tibco.tibjms.TibjmsxLinkTcp$LinkReader.work(TibjmsxLinkTcp.java:330) [tibjms.jar:6.3.0]
        at com.tibco.tibjms.TibjmsxLinkTcp$LinkReader.run(TibjmsxLinkTcp.java:259) [tibjms.jar:6.3.0]

处理在侦听器端继续,一旦侦听器完成处理消息,我会收到以下异常:

07:28:04.281 [jmsContainer-1] WARN  o.s.j.l.DefaultMessageListenerContainer - Execution of JMS message listener failed, and no ErrorHandler has been set.
javax.jms.IllegalStateException: Session is closed
        at com.tibco.tibjms.TibjmsxSessionImp.getTransacted(TibjmsxSessionImp.java:4837) ~[tibjms.jar:6.3.0]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_03]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_03]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_03]
        at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_03]
        at org.springframework.jms.connection.CachingConnectionFactory$CachedSessionInvocationHandler.invoke(CachingConnectionFactory.java:344) ~[org.springframework.jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
        at $Proxy20.getTransacted(Unknown Source) ~[na:na]
        at org.springframework.jms.listener.AbstractMessageListenerContainer.commitIfNecessary(AbstractMessageListenerContainer.java:572) ~[org.springframework.jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
        at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:481) ~[org.springframework.jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
        at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:325) [org.springframework.jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
        at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:263) [org.springframework.jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
        at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1059) [org.springframework.jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
        at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1051) [org.springframework.jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
        at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:948) [org.springframework.jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
        at java.lang.Thread.run(Thread.java:722) [na:1.7.0_03]
07:28:04.281 [jmsContainer-1] WARN  o.s.j.l.DefaultMessageListenerContainer - Setup of JMS message listener invoker failed for destination 'Queue[cmb.cmbtech.na.bead_153036.rwacalrequest1]' - trying to recover. Cause: Session is closed
javax.jms.IllegalStateException: Session is closed
        at com.tibco.tibjms.TibjmsxSessionImp.getTransacted(TibjmsxSessionImp.java:4837) ~[tibjms.jar:6.3.0]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_03]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_03]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_03]
        at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_03]
        at org.springframework.jms.connection.CachingConnectionFactory$CachedSessionInvocationHandler.invoke(CachingConnectionFactory.java:344) ~[org.springframework.jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
        at $Proxy20.getTransacted(Unknown Source) ~[na:na]
        at org.springframework.jms.listener.AbstractMessageListenerContainer.commitIfNecessary(AbstractMessageListenerContainer.java:572) ~[org.springframework.jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
        at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:481) ~[org.springframework.jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
        at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:325) ~[org.springframework.jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
        at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:263) ~[org.springframework.jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
        at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1059) ~[org.springframework.jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
        at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1051) ~[org.springframework.jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
        at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:948) ~[org.springframework.jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
        at java.lang.Thread.run(Thread.java:722) [na:1.7.0_03]

最后,在上述异常发生几秒钟后,我在日志中得到以下信息

07:28:04.418 [jmsContainer-1] INFO  o.s.j.l.DefaultMessageListenerContainer - Successfully refreshed JMS Connection

我不太确定是什么导致了问题,但似乎只要侦听器花费超过几分钟的时间来处理消息,jms 连接就会被重置。所有这些的副作用是侦听器无法将处理输出发布到另一个队列以供外部应用程序使用。我是否需要为我的侦听器设置事务管理器或设置某种在给定持续时间内不会重置连接的属性?

4

0 回答 0