SingleConnectionFactory - 引发 ConcurrentModificationException
SingleConnectionFactory - raises ConcurrentModificationException
我使用多个 SimpleMessageListenerContainer,它们都使用来自 SingleConnectionFactory 的相同连接。它们都注册在 SingleConnectionFactory 的 AggregatedExceptionListener 中。因为,当 SingleConnectionFactory 的 JMS Connection 断开时,需要通知所有的 SMLC 清除它们的 Session 和 Consumers,然后去从 SCF 获取新的 Connection。
但是,当 SingleConnectionFactory 的 AggregatedExceptionListener 迭代其 "this.delegates" 并尝试调用 "listener.onException()"(例如,我所有的 SMLC 都是委托)时会发生此错误。
Spring class 中会出现错误。它也许应该复制委托,然后遍历复制的列表,因此如果列表被修改,它不会引发 ConcurrentModificationException。
如有任何变通办法,我们将不胜感激。
13:30:28,201 ERROR [SimpleMessageListenerContainer] Encountered non-recoverable JMSException
javax.jms.JMSException: java.io.EOFException
at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:54)
at org.apache.activemq.ActiveMQConnection.onAsyncException(ActiveMQConnection.java:1998)
at org.apache.activemq.ActiveMQConnection.onException(ActiveMQConnection.java:2017)
at org.apache.activemq.transport.TransportFilter.onException(TransportFilter.java:101)
at org.apache.activemq.transport.ResponseCorrelator.onException(ResponseCorrelator.java:126)
at org.apache.activemq.transport.TransportFilter.onException(TransportFilter.java:101)
at org.apache.activemq.transport.TransportFilter.onException(TransportFilter.java:101)
at org.apache.activemq.transport.WireFormatNegotiator.onException(WireFormatNegotiator.java:160)
at org.apache.activemq.transport.AbstractInactivityMonitor.onException(AbstractInactivityMonitor.java:314)
at org.apache.activemq.transport.TransportSupport.onException(TransportSupport.java:96)
at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:200)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.EOFException
at java.io.DataInputStream.readInt(Unknown Source)
at org.apache.activemq.openwire.OpenWireFormat.unmarshal(OpenWireFormat.java:258)
at org.apache.activemq.transport.tcp.TcpTransport.readCommand(TcpTransport.java:221)
at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:213)
at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:196)
... 1 more
Exception in thread "ActiveMQ Connection Executor: tcp://localhost/127.0.0.1:9002@58017" java.util.ConcurrentModificationException
at java.util.LinkedHashMap$LinkedHashIterator.nextNode(Unknown Source)
at java.util.LinkedHashMap$LinkedKeyIterator.next(Unknown Source)
at org.springframework.jms.connection.SingleConnectionFactory$AggregatedExceptionListener.onException(SingleConnectionFactory.java:670)
at org.apache.activemq.ActiveMQConnection.run(ActiveMQConnection.java:2005)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
如您所料,这是一个错误,请参阅 https://jira.spring.io/browse/SPR-13421。
它应该会在计划于 2015 年 10 月 15 日发布的即将发布的 4.1.8 和 4.2.2 版本中得到修复。
我使用多个 SimpleMessageListenerContainer,它们都使用来自 SingleConnectionFactory 的相同连接。它们都注册在 SingleConnectionFactory 的 AggregatedExceptionListener 中。因为,当 SingleConnectionFactory 的 JMS Connection 断开时,需要通知所有的 SMLC 清除它们的 Session 和 Consumers,然后去从 SCF 获取新的 Connection。
但是,当 SingleConnectionFactory 的 AggregatedExceptionListener 迭代其 "this.delegates" 并尝试调用 "listener.onException()"(例如,我所有的 SMLC 都是委托)时会发生此错误。
Spring class 中会出现错误。它也许应该复制委托,然后遍历复制的列表,因此如果列表被修改,它不会引发 ConcurrentModificationException。
如有任何变通办法,我们将不胜感激。
13:30:28,201 ERROR [SimpleMessageListenerContainer] Encountered non-recoverable JMSException
javax.jms.JMSException: java.io.EOFException
at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:54)
at org.apache.activemq.ActiveMQConnection.onAsyncException(ActiveMQConnection.java:1998)
at org.apache.activemq.ActiveMQConnection.onException(ActiveMQConnection.java:2017)
at org.apache.activemq.transport.TransportFilter.onException(TransportFilter.java:101)
at org.apache.activemq.transport.ResponseCorrelator.onException(ResponseCorrelator.java:126)
at org.apache.activemq.transport.TransportFilter.onException(TransportFilter.java:101)
at org.apache.activemq.transport.TransportFilter.onException(TransportFilter.java:101)
at org.apache.activemq.transport.WireFormatNegotiator.onException(WireFormatNegotiator.java:160)
at org.apache.activemq.transport.AbstractInactivityMonitor.onException(AbstractInactivityMonitor.java:314)
at org.apache.activemq.transport.TransportSupport.onException(TransportSupport.java:96)
at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:200)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.EOFException
at java.io.DataInputStream.readInt(Unknown Source)
at org.apache.activemq.openwire.OpenWireFormat.unmarshal(OpenWireFormat.java:258)
at org.apache.activemq.transport.tcp.TcpTransport.readCommand(TcpTransport.java:221)
at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:213)
at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:196)
... 1 more
Exception in thread "ActiveMQ Connection Executor: tcp://localhost/127.0.0.1:9002@58017" java.util.ConcurrentModificationException
at java.util.LinkedHashMap$LinkedHashIterator.nextNode(Unknown Source)
at java.util.LinkedHashMap$LinkedKeyIterator.next(Unknown Source)
at org.springframework.jms.connection.SingleConnectionFactory$AggregatedExceptionListener.onException(SingleConnectionFactory.java:670)
at org.apache.activemq.ActiveMQConnection.run(ActiveMQConnection.java:2005)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
如您所料,这是一个错误,请参阅 https://jira.spring.io/browse/SPR-13421。
它应该会在计划于 2015 年 10 月 15 日发布的即将发布的 4.1.8 和 4.2.2 版本中得到修复。