关键字: activemq error 1.DefaultMessageListenerContainer stops consuming after inactivity
Example exception trace repeated in logs
[ERROR] 2008-08-12 15:16:57 method: org.springframework.jms.listener.DefaultMessageListenerContainer.handleListenerSetupFailure(DefaultMessageListenerContainer.java:666)
Setup of JMS message listener invoker failed - trying to recover
javax.jms.IllegalStateException: The Consumer is closed
at org.apache.activemq.ActiveMQMessageConsumer.checkClosed(ActiveMQMessageConsumer.java:612)
at org.apache.activemq.ActiveMQMessageConsumer.receive(ActiveMQMessageConsumer.java:467)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveMessage(AbstractPollingMessageListenerContainer.java:375)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:300)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:254)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:870)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:810)
at java.lang.Thread.run(Thread.java:595)
I guess this is an Active MQ bug which should have been fixed in Version 5.2 (see active MQ forum and jira for this)
The problem is a bug in the Inactivity Monitor which is not working properly in versions < 5.2. and blocking after getting the ConnectionInactive for too long exception.
Since i still use 4.1.1 i tried the fix using tcp url and setting the wiredFormat.maxInactivityDuration parameter within the url and it seams to work now.
But nevertheless the problem now is that i don't have the failover handling so i hope my broker will never die ...
Resolution:
versus on the consumer/producer, e.g.,
Effects:
failover depends on the InactivityMonitor - but also socket death too
- which might take a while to percolate through.
maxInactivityDuration=0 这样的参数,否则当一段时间没有消息发送时会抛出"Channel was inactive for too long"
如果maxInactivityDuration=0,当重启应用时,测试发现,监听器将不能接收消息了 ,也许应该像下面这样:
2.ActiveMQ broker brokes down on client reconnect
Example exception trace repeated in logs
javax.jms.InvalidClientIDException: Broker: 10.155.1.179 - Client: clientId_50002500 already connected from /10.159.226.179:2222
at org.apache.activemq.broker.region.RegionBroker.addConnection(RegionBroker.java:205)
at org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:81)
at org.apache.activemq.advisory.AdvisoryBroker.addConnection(AdvisoryBroker.java:72)
at org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:81)
at org.apache.activemq.broker.MutableBrokerFilter.addConnection(MutableBrokerFilter.java:91)
at org.apache.activemq.broker.TransportConnection.processAddConnection(TransportConnection.java:657)
at org.apache.activemq.broker.jmx.ManagedTransportConnection.processAddConnection(ManagedTransportConnection.java:86)
at org.apache.activemq.command.ConnectionInfo.visit(ConnectionInfo.java:125)
at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:281)
at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:178)
at org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:67)
at org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:134)
at org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:138)
at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:185)
at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:172)
at java.lang.Thread.run(Thread.java:595)
When unplugging cable from
the broker and then pluging it in again, client tries to reconnect, but in
broker old client connection still exists and broker fails with lots of
different exceptions going one after another.
The queues after that become corrupted somehow and you need to restart the
broker.
Example exception trace repeated in logs
[ERROR] 2008-08-12 15:16:57 method: org.springframework.jms.listener.DefaultMessageListenerContainer.handleListenerSetupFailure(DefaultMessageListenerContainer.java:666)
Setup of JMS message listener invoker failed - trying to recover
javax.jms.IllegalStateException: The Consumer is closed
at org.apache.activemq.ActiveMQMessageConsumer.checkClosed(ActiveMQMessageConsumer.java:612)
at org.apache.activemq.ActiveMQMessageConsumer.receive(ActiveMQMessageConsumer.java:467)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveMessage(AbstractPollingMessageListenerContainer.java:375)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:300)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:254)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:870)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:810)
at java.lang.Thread.run(Thread.java:595)
I guess this is an Active MQ bug which should have been fixed in Version 5.2 (see active MQ forum and jira for this)
The problem is a bug in the Inactivity Monitor which is not working properly in versions < 5.2. and blocking after getting the ConnectionInactive for too long exception.
Since i still use 4.1.1 i tried the fix using tcp url and setting the wiredFormat.maxInactivityDuration parameter within the url and it seams to work now.
But nevertheless the problem now is that i don't have the failover handling so i hope my broker will never die ...
Resolution:
- <transportConnectors>
- <transportConnector name="openwire"
- uri="tcp://localhost:61616?wireFormat.maxInactivityDuration=0"/>
- </transportConnectors>
<transportConnectors>
<transportConnector name="openwire"
uri="tcp://localhost:61616?wireFormat.maxInactivityDuration=0"/>
</transportConnectors>
versus on the consumer/producer, e.g.,
- ActiveMQConnectionFactory connectionFactory = new
- ActiveMQConnectionFactory("failover:(tcp://brokerhost:61616)?wireFormat.maxInactivityDuration=0");
ActiveMQConnectionFactory connectionFactory = new
ActiveMQConnectionFactory("failover:(tcp://brokerhost:61616)?wireFormat.maxInactivityDuration=0");
Effects:
failover depends on the InactivityMonitor - but also socket death too
- which might take a while to percolate through.
maxInactivityDuration=0 这样的参数,否则当一段时间没有消息发送时会抛出"Channel was inactive for too long"
- <bean
- class="org.apache.activemq.ActiveMQConnectionFactory">
- <property name="brokerURL">
- <value>tcp://localhost:61616?connectionTimeout=0&wireFormat.maxInactivityDuration=0</value>
- </property>
- </bean>
<bean
class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL">
<value>tcp://localhost:61616?connectionTimeout=0&wireFormat.maxInactivityDuration=0</value>
</property>
</bean>
如果maxInactivityDuration=0,当重启应用时,测试发现,监听器将不能接收消息了 ,也许应该像下面这样:
- <bean id="queueConnectionFactory"
- class="org.apache.activemq.spring.ActiveMQConnectionFactory">
- <property name="brokerURL"
- value="failover:(tcp://195.2.199.9:61616?wireFormat.maxInactivityDuration=1000)&maxReconnectDelay=1000"/>
- <property name="useAsyncSend" value="true"/>
- </bean>
<bean id="queueConnectionFactory"
class="org.apache.activemq.spring.ActiveMQConnectionFactory">
<property name="brokerURL"
value="failover:(tcp://195.2.199.9:61616?wireFormat.maxInactivityDuration=1000)&maxReconnectDelay=1000"/>
<property name="useAsyncSend" value="true"/>
</bean>
2.ActiveMQ broker brokes down on client reconnect
Example exception trace repeated in logs
javax.jms.InvalidClientIDException: Broker: 10.155.1.179 - Client: clientId_50002500 already connected from /10.159.226.179:2222
at org.apache.activemq.broker.region.RegionBroker.addConnection(RegionBroker.java:205)
at org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:81)
at org.apache.activemq.advisory.AdvisoryBroker.addConnection(AdvisoryBroker.java:72)
at org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:81)
at org.apache.activemq.broker.MutableBrokerFilter.addConnection(MutableBrokerFilter.java:91)
at org.apache.activemq.broker.TransportConnection.processAddConnection(TransportConnection.java:657)
at org.apache.activemq.broker.jmx.ManagedTransportConnection.processAddConnection(ManagedTransportConnection.java:86)
at org.apache.activemq.command.ConnectionInfo.visit(ConnectionInfo.java:125)
at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:281)
at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:178)
at org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:67)
at org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:134)
at org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:138)
at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:185)
at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:172)
at java.lang.Thread.run(Thread.java:595)
When unplugging cable from
the broker and then pluging it in again, client tries to reconnect, but in
broker old client connection still exists and broker fails with lots of
different exceptions going one after another.
The queues after that become corrupted somehow and you need to restart the
broker.