java ActiveMQ:“通道不活动太久”异常停止代理消息传递
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16320022/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ActiveMQ:'channel inactive for too long' exceptions stop broker messaging
提问by shuttsy
My system has the following parts:
我的系统有以下几个部分:
- ActiveMQ broker exposed on tcp, port 61616
- 3 Grails/Spring wars that live in their own Tomcat servers, they publish and consume messages to the JMS broker
- n times remote client system with a JMS listener component to receive client specific messages, connect to the JMS broker through VPN using a hostname and port 61616
- ActiveMQ 代理暴露在 tcp 端口 61616 上
- 3 Grails/Spring War存在于它们自己的 Tomcat 服务器中,它们向 JMS 代理发布和使用消息
- n 次远程客户端系统,带有 JMS 侦听器组件以接收客户端特定消息,使用主机名和端口 61616 通过 VPN 连接到 JMS 代理
So far, all works fine throughout dev, Test and production environments.
到目前为止,在开发、测试和生产环境中一切正常。
We've just connected a new client system in production and we've noticed that it's logs start to report 'channel was inactive for too long' exceptions and drops the connection. Worrying the overall effect of this one client is that it stops all message consumption on the broker so brings are whole system to a halt.
我们刚刚在生产中连接了一个新的客户端系统,我们注意到它的日志开始报告“通道不活动太久”异常并断开连接。担心这个客户端的整体影响是它停止了代理上的所有消息消耗,从而使整个系统停止。
This client listener (using Spring caching connection factory) appears to connect to the JMS broker ok, process some messages, then 3 mins reports the exception. Turned on DEBUG in ActiveMQ and got loads of output, nothing suggesting a warning or error on the broker around the same time though.
此客户端侦听器(使用 Spring 缓存连接工厂)似乎可以正常连接到 JMS 代理,处理一些消息,然后 3 分钟报告异常。在 ActiveMQ 中打开 DEBUG 并获得大量输出,但没有任何迹象表明同时在代理上出现警告或错误。
Believe that ActiveMQ has some internal keep alive that should keep the connection even if inactive for longer than the default 30 seconds.
相信 ActiveMQ 有一些内部保持活动,即使不活动时间超过默认 30 秒,也应该保持连接。
Infrastructure guys have monitored the VPN of this client and confirm it stays up and connected the whole time.
基础设施人员已经监控了这个客户端的 VPN,并确认它一直保持连接状态。
Don't believe it is code or Spring config that is at fault, as we have numerous other instances of the listener in different clients and they all behave themselves fine.
不要相信是代码或 Spring 配置有问题,因为我们在不同的客户端中有许多其他的侦听器实例,它们都表现得很好。
Suppose I have 2 questions really:
假设我真的有两个问题:
- What is causing 'channel inactive' exceptions?
- Why does this exception in a single client stop ActiveMQ from working?
- 是什么导致“通道不活动”异常?
- 为什么单个客户端中的此异常会阻止 ActiveMQ 工作?
EDIT - adding exception stacktrace:
编辑 - 添加异常堆栈跟踪:
2013-04-24 14:02:06,359 WARN - Encountered a JMSException - resetting the underlying JMS Connection (org.springframework.jms.connection.CachingConnectionFactory)
javax.jms.JMSException: Channel was inactive for too (>30000) long: jmsserver/xxx.xx.xx.xxx:61616
at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:49)
at org.apache.activemq.ActiveMQConnection.onAsyncException(ActiveMQConnection.java:1833)
at org.apache.activemq.ActiveMQConnection.onException(ActiveMQConnection.java:1850)
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.InactivityMonitor.onException(InactivityMonitor.java:266)
at org.apache.activemq.transport.InactivityMonitor.run(InactivityMonitor.java:186)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:693)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:719)
at java.lang.Thread.run(Thread.java:813)
Caused by: org.apache.activemq.transport.InactivityIOException: Channel was inactive for too (>30000) long: jmsserver/xxx.xx.xx.xxx:61616
... 4 more
回答by ali haider
Have you tried the following:
您是否尝试过以下操作:
Disable the InactivityMonitor; wireFormat.maxInactivityDuration=0 e.g.
URL: tcp://localhost:61616?wireFormat.maxInactivityDuration=0
If you don't wish to disable, have you tried setting it to a high number e.g.: URL:
tcp://localhost:61616?wireFormat.maxInactivityDuration=5000000 (just an example - use your own time in ms)
Also, ensure that the jar files are the same version for both client and server.
禁用 InactivityMonitor;wireFormat.maxInactivityDuration=0 例如
网址:tcp://localhost:61616?wireFormat.maxInactivityDuration=0
如果您不想禁用,您是否尝试将其设置为较高的数字,例如:URL:
tcp://localhost:61616?wireFormat.maxInactivityDuration=5000000 (just an example - use your own time in ms)
此外,请确保客户端和服务器的 jar 文件版本相同。
Hope it helps
希望能帮助到你
回答by kungkk
You just need to change the activemq.xml (configuration file):
你只需要更改activemq.xml(配置文件):
- transportConnectors section:
- 运输连接器部分:
transportConnector name="ws" uri="ws://0.0.0.0:61614" change transportConnector name="ws" uri="tcp://0.0.0.0:61614"
transportConnector name="ws" uri="ws://0.0.0.0:61614" 更改 transportConnector name="ws" uri="tcp://0.0.0.0:61614"
It works for my windows and linux virtual machines
它适用于我的 windows 和 linux 虚拟机