activemq 错误收集

  关键字: 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:

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

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

Java代码 
  1. ActiveMQConnectionFactory connectionFactory = new  
  2. 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"

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>   
<bean 
class="org.apache.activemq.ActiveMQConnectionFactory"> 
<property name="brokerURL"> 
<value>tcp://localhost:61616?connectionTimeout=0&wireFormat.maxInactivityDuration=0</value> 
</property> 
</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>  
    <bean id="queueConnectionFactory"
        class="org.apache.activemq.spring.ActiveMQConnectionFactory">
		<property name="brokerURL"
		 value="failover:(tcp://195.2.199.9:61616?wireFormat.maxInactivityDuration=1000)&amp;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.
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值