activemq 错误收集

来源:互联网 发布:php exec 返回值127 编辑:程序博客网 时间:2024/06/05 16:59
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:

Java代码
  1. <transportConnectors>
  2. <transportConnector name="openwire"
  3. uri="tcp://localhost:61616?wireFormat.maxInactivityDuration=0"/>
  4. </transportConnectors>
[java] view plaincopyprint?
  1. <transportConnectors>
  2. <transportConnector name="openwire"
  3. uri="tcp://localhost:61616?wireFormat.maxInactivityDuration=0"/>
  4. </transportConnectors>

versus on the consumer/producer, e.g.,

Java代码
  1. ActiveMQConnectionFactory connectionFactory = new
  2. ActiveMQConnectionFactory("failover:(tcp://brokerhost:61616)?wireFormat.maxInactivityDuration=0");
[java] view plaincopyprint?
  1. ActiveMQConnectionFactory connectionFactory = new
  2. 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"

Java代码
  1. <bean
  2. class="org.apache.activemq.ActiveMQConnectionFactory">
  3. <property name="brokerURL">
  4. <value>tcp://localhost:61616?connectionTimeout=0&wireFormat.maxInactivityDuration=0</value>
  5. </property>
  6. </bean>
[java] view plaincopyprint?
  1. <bean
  2. class="org.apache.activemq.ActiveMQConnectionFactory">
  3. <property name="brokerURL">
  4. <value>tcp://localhost:61616?connectionTimeout=0&wireFormat.maxInactivityDuration=0</value>
  5. </property>
  6. </bean>


如果maxInactivityDuration=0,当重启应用时,测试发现,监听器将不能接收消息了 ,也许应该像下面这样:
Java代码
  1. <bean id="queueConnectionFactory"
  2. class="org.apache.activemq.spring.ActiveMQConnectionFactory">
  3. <property name="brokerURL"
  4. value="failover:(tcp://195.2.199.9:61616?wireFormat.maxInactivityDuration=1000)&amp;maxReconnectDelay=1000"/>
  5. <property name="useAsyncSend" value="true"/>
  6. </bean>
[java] view plaincopyprint?
  1. <bean id="queueConnectionFactory"
  2. class="org.apache.activemq.spring.ActiveMQConnectionFactory">
  3. <property name="brokerURL"
  4. value="failover:(tcp://195.2.199.9:61616?wireFormat.maxInactivityDuration=1000)&amp;maxReconnectDelay=1000"/>
  5. <property name="useAsyncSend" value="true"/>
  6. </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.

收做笔记,来自:http://blog.csdn.net/xiaoming444/article/details/3536915

原创粉丝点击