Erratic javax.jms.JMSException: Peer disposed

2019-06-28 02:22发布

问题:

I have a erratic problem with Java JMS. For moments works fine, but throws the following exception erratically and cut the execution.

It is important to note that this occurs without stopping the broker.

javax.jms.JMSException: Peer (vm://test#1) disposed.
        at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:49)
        at org.apache.activemq.ActiveMQConnection.onAsyncException(ActiveMQConnection.java:1773)
        at org.apache.activemq.ActiveMQConnection.onException(ActiveMQConnection.java:1790)
        at org.apache.activemq.transport.TransportFilter.onException(TransportFilter.java:99)
        at org.apache.activemq.transport.ResponseCorrelator.onException(ResponseCorrelator.java:114)
        at org.apache.activemq.transport.TransportFilter.onException(TransportFilter.java:99)
        at org.apache.activemq.transport.vm.VMTransport.iterate(VMTransport.java:203)
        at org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:122)
        at org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:43)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)
Caused by: org.apache.activemq.transport.TransportDisposedIOException: Peer (vm://test#1) disposed.

回答1:

I think it could be this issue with ActiveMQ: https://issues.apache.org/jira/browse/AMQ-2902

This issue tracker thread says that it is harmless (it is just a noisy INFO level log message), and that it is fixed in ActiveMQ 5.4.2.

On the other hand, you say that the exception "cut the execution" ... which could mean that this is a different issue to yours ...

UPDATE

Anyone getting a "peer disposed" exception that isn't fixed by upgrading ActiveMQ, and isn't related to shutdown (see Unable to shutdown embedded activeMQ service using the built in BrokerService.stop call) should consider lodging a bug report.



回答2:

It would seem the poster's issue is completely different. The link mentions a noisy INFO level log message, but the above (which is also what I'm getting) is a thrown JMSException, which has these additional lines from the Caused by: clause.

    at org.apache.activemq.transport.vm.VMTransport.oneway(VMTransport.java:88)
    at org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.java:68)
    at org.apache.activemq.transport.ResponseCorrelator.oneway(ResponseCorrelator.java:60)
    at org.apache.activemq.ActiveMQConnection.doAsyncSendPacket(ActiveMQConnection.java:1275)
    ... 31 more

The odd part is that there is a connection.isClosed() check before it gets this far. So the connection is open, but the 'peer' is still disposed. From researching other potential answers online, the only possible solution is that the connection to the broker is intact, but the specific queue may be closed.

For my particular similar case, this occurred when the broker was stopped, but consumers and producers were still attempting to establish connections. Sometimes the connection would still be considered open (i.e., not closed even though the broker was stopped). Fixing this to ensure the broker did not die fixed my problem.

I also wanted to add that this issue I've seen in ActiveMQ 5.6 (but I haven't tested in 5.8).