在我们尝试将spring-jms-4.0.2升级到4.3.8并且activemq保持在5.13.0之后,我们遇到了一个奇怪的问题。
我们目睹的是在spring-jms或activemq方面的连续循环,并且在我们在Tomcat中启动应用程序后,CPU始终固定在20-40左右的范围内。
如果我们回去并且只是用4.0.2版本替换lib中的spring-jms 4.3.8,那么一切都在开始后正常运行。
并发使用者为2,缓存级别设置为3,用于" DefaultMessageListenerContainer"在春天。
以下是几个指标:
我们启用了springframework和activemq的调试日志记录,我们在spring log中看到的只有3行,而不管spring jms jar版本。
2017-06-22T12:09:02,928 DEBUG [org.springframework.jms.listener.DefaultMessageListenerContainer] Established shared JMS Connection
2017-06-22T12:09:02,930 DEBUG [org.springframework.jms.listener.DefaultMessageListenerContainer] Resumed paused task: org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker@bd71008
2017-06-22T12:09:02,930 DEBUG [org.springframework.jms.listener.DefaultMessageListenerContainer] Resumed paused task: org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker@7814de81
但这是activemq日志之间的区别
当我们使用spring-jms-4.0.2时
2017-06-22 12:00:46,921 | DEBUG | Received WireFormat: WireFormatInfo { version=11, properties={TcpNoDelayEnabled=true, SizePrefixDisabled=false, CacheSize=1024, StackTraceEnabled=true, CacheEnabled=true, TightEncodingEnabled=true, MaxFrameSize=9223372036854775807, MaxInactivityDuration=30000, MaxInactivityDurationInitalDelay=30000}, magic=[A,c,t,i,v,e,M,Q]} | org.apache.activemq.transport.WireFormatNegotiator | ActiveMQ Transport: tcp:///127.0.0.1:49504@61616
2017-06-22 12:00:46,922 | DEBUG | tcp:///127.0.0.1:49504@61616 before negotiation: OpenWireFormat{version=11, cacheEnabled=false, stackTraceEnabled=false, tightEncodingEnabled=false, sizePrefixDisabled=false, maxFrameSize=9223372036854775807} | org.apache.activemq.transport.WireFormatNegotiator | ActiveMQ Transport: tcp:///127.0.0.1:49504@61616
2017-06-22 12:00:46,922 | DEBUG | tcp:///127.0.0.1:49504@61616 after negotiation: OpenWireFormat{version=11, cacheEnabled=true, stackTraceEnabled=true, tightEncodingEnabled=true, sizePrefixDisabled=false, maxFrameSize=9223372036854775807} | org.apache.activemq.transport.WireFormatNegotiator | ActiveMQ Transport: tcp:///127.0.0.1:49504@61616
2017-06-22 12:00:46,927 | DEBUG | Setting up new connection id: ID:39235aa-49503-1498147246722-1:1, address: tcp://127.0.0.1:49504, info: ConnectionInfo {commandId = 1, responseRequired = true, connectionId = ID:39235aa-49503-1498147246722-1:1, clientId = ID:39235aa-49503-1498147246722-0:1, clientIp = null, userName = null, password = *****, brokerPath = null, brokerMasterConnector = false, manageable = true, clientMaster = true, faultTolerant = true, failoverReconnect = false} | org.apache.activemq.broker.TransportConnection | ActiveMQ Transport: tcp:///127.0.0.1:49504@61616
2017-06-22 12:00:46,935 | DEBUG | Tomcat01.CE01 adding consumer: ID:39235aa-49503-1498147246722-1:1:-1:1 for destination: ActiveMQ.Advisory.TempQueue,ActiveMQ.Advisory.TempTopic | org.apache.activemq.broker.region.AbstractRegion | ActiveMQ Transport: tcp:///127.0.0.1:49504@61616
2017-06-22 12:00:46,973 | DEBUG | Tomcat01.CE01 adding consumer: ID:39235aa-49503-1498147246722-1:1:2:1 for destination: queue://company.CD.Tomcat01.Repo.Request | org.apache.activemq.broker.region.AbstractRegion | ActiveMQ Transport: tcp:///127.0.0.1:49504@61616
2017-06-22 12:00:46,976 | DEBUG | queue://company.CD.Tomcat01.Repo.Request add sub: QueueSubscription: consumer=ID:39235aa-49503-1498147246722-1:1:2:1, destinations=0, dispatched=0, delivered=0, pending=0, dequeues: 0, dispatched: 0, inflight: 0 | org.apache.activemq.broker.region.Queue | ActiveMQ Transport: tcp:///127.0.0.1:49504@61616
2017-06-22 12:00:46,976 | DEBUG | queue://company.CD.Tomcat01.Repo.Request, subscriptions=1, memory=0%, size=0, pending=0 toPageIn: 0, Inflight: 0, pagedInMessages.size 0, pagedInPendingDispatch.size 0, enqueueCount: 0, dequeueCount: 0, memUsage:0 | org.apache.activemq.broker.region.Queue | Queue:company.CD.Tomcat01.Repo.Request
2017-06-22 12:00:46,976 | DEBUG | Tomcat01.CE01 adding consumer: ID:39235aa-49503-1498147246722-1:1:1:1 for destination: queue://company.CD.Tomcat01.Repo.Request | org.apache.activemq.broker.region.AbstractRegion | ActiveMQ Transport: tcp:///127.0.0.1:49504@61616
2017-06-22 12:00:46,977 | DEBUG | queue://company.CD.Tomcat01.Repo.Request add sub: QueueSubscription: consumer=ID:39235aa-49503-1498147246722-1:1:1:1, destinations=0, dispatched=0, delivered=0, pending=0, dequeues: 0, dispatched: 0, inflight: 0 | org.apache.activemq.broker.region.Queue | ActiveMQ Transport: tcp:///127.0.0.1:49504@61616
2017-06-22 12:00:46,977 | DEBUG | queue://company.CD.Tomcat01.Repo.Request, subscriptions=2, memory=0%, size=0, pending=0 toPageIn: 0, Inflight: 0, pagedInMessages.size 0, pagedInPendingDispatch.size 0, enqueueCount: 0, dequeueCount: 0, memUsage:0 | org.apache.activemq.broker.region.Queue | Queue:company.CD.Tomcat01.Repo.Request
2017-06-22 12:00:46,978 | DEBUG | queue://company.CD.Tomcat01.Repo.Request, subscriptions=2, memory=0%, size=0, pending=0 toPageIn: 0, Inflight: 0, pagedInMessages.size 0, pagedInPendingDispatch.size 0, enqueueCount: 0, dequeueCount: 0, memUsage:0 | org.apache.activemq.broker.region.Queue | ActiveMQ Transport: tcp:///127.0.0.1:49504@61616
2017-06-22 12:00:46,978 | DEBUG | queue://company.CD.Tomcat01.Repo.Request, subscriptions=2, memory=0%, size=0, pending=0 toPageIn: 0, Inflight: 0, pagedInMessages.size 0, pagedInPendingDispatch.size 0, enqueueCount: 0, dequeueCount: 0, memUsage:0 | org.apache.activemq.broker.region.Queue | ActiveMQ Transport: tcp:///127.0.0.1:49504@61616
2017-06-22 12:01:04,340 | DEBUG | queue://company.CD.Tomcat01.Repo.Request expiring messages .. | org.apache.activemq.broker.region.Queue | ActiveMQ Broker[Tomcat01.CE01] Scheduler
2017-06-22 12:01:04,342 | DEBUG | queue://company.CD.Tomcat01.Repo.Request expiring messages done. | org.apache.activemq.broker.region.Queue | ActiveMQ Broker[Tomcat01.CE01] Scheduler
2017-06-22 12:01:04,342 | DEBUG | queue://company.CD.Tomcat01.Repo.Request, subscriptions=2, memory=0%, size=0, pending=0 toPageIn: 0, Inflight: 0, pagedInMessages.size 0, pagedInPendingDispatch.size 0, enqueueCount: 0, dequeueCount: 0, memUsage:0 | org.apache.activemq.broker.region.Queue | Queue:company.CD.Tomcat01.Repo.Request
而且,当我们使用升级的spring-jms-4.3.8或.9
时2017-06-22 12:09:03,037 | DEBUG | Received WireFormat: WireFormatInfo { version=11, properties={TcpNoDelayEnabled=true, SizePrefixDisabled=false, CacheSize=1024, StackTraceEnabled=true, CacheEnabled=true, TightEncodingEnabled=true, MaxFrameSize=9223372036854775807, MaxInactivityDuration=30000, MaxInactivityDurationInitalDelay=30000}, magic=[A,c,t,i,v,e,M,Q]} | org.apache.activemq.transport.WireFormatNegotiator | ActiveMQ Transport: tcp:///127.0.0.1:49636@61616
2017-06-22 12:09:03,037 | DEBUG | tcp:///127.0.0.1:49636@61616 before negotiation: OpenWireFormat{version=11, cacheEnabled=false, stackTraceEnabled=false, tightEncodingEnabled=false, sizePrefixDisabled=false, maxFrameSize=9223372036854775807} | org.apache.activemq.transport.WireFormatNegotiator | ActiveMQ Transport: tcp:///127.0.0.1:49636@61616
2017-06-22 12:09:03,038 | DEBUG | tcp:///127.0.0.1:49636@61616 after negotiation: OpenWireFormat{version=11, cacheEnabled=true, stackTraceEnabled=true, tightEncodingEnabled=true, sizePrefixDisabled=false, maxFrameSize=9223372036854775807} | org.apache.activemq.transport.WireFormatNegotiator | ActiveMQ Transport: tcp:///127.0.0.1:49636@61616
2017-06-22 12:09:03,043 | DEBUG | Setting up new connection id: ID:39235aa-49635-1498147742821-1:1, address: tcp://127.0.0.1:49636, info: ConnectionInfo {commandId = 1, responseRequired = true, connectionId = ID:39235aa-49635-1498147742821-1:1, clientId = ID:39235aa-49635-1498147742821-0:1, clientIp = null, userName = null, password = *****, brokerPath = null, brokerMasterConnector = false, manageable = true, clientMaster = true, faultTolerant = true, failoverReconnect = false} | org.apache.activemq.broker.TransportConnection | ActiveMQ Transport: tcp:///127.0.0.1:49636@61616
2017-06-22 12:09:03,051 | DEBUG | Tomcat01.CE01 adding consumer: ID:39235aa-49635-1498147742821-1:1:-1:1 for destination: ActiveMQ.Advisory.TempQueue,ActiveMQ.Advisory.TempTopic | org.apache.activemq.broker.region.AbstractRegion | ActiveMQ Transport: tcp:///127.0.0.1:49636@61616
2017-06-22 12:09:03,092 | DEBUG | Tomcat01.CE01 adding consumer: ID:39235aa-49635-1498147742821-1:1:2:1 for destination: queue://company.CD.Tomcat01.Repo.Request | org.apache.activemq.broker.region.AbstractRegion | ActiveMQ Transport: tcp:///127.0.0.1:49636@61616
2017-06-22 12:09:03,095 | DEBUG | queue://company.CD.Tomcat01.Repo.Request add sub: QueueSubscription: consumer=ID:39235aa-49635-1498147742821-1:1:2:1, destinations=0, dispatched=0, delivered=0, pending=0, dequeues: 0, dispatched: 0, inflight: 0 | org.apache.activemq.broker.region.Queue | ActiveMQ Transport: tcp:///127.0.0.1:49636@61616
2017-06-22 12:09:03,095 | DEBUG | queue://company.CD.Tomcat01.Repo.Request, subscriptions=1, memory=0%, size=0, pending=0 toPageIn: 0, Inflight: 0, pagedInMessages.size 0, pagedInPendingDispatch.size 0, enqueueCount: 0, dequeueCount: 0, memUsage:0 | org.apache.activemq.broker.region.Queue | Queue:company.CD.Tomcat01.Repo.Request
2017-06-22 12:09:03,096 | DEBUG | Tomcat01.CE01 adding consumer: ID:39235aa-49635-1498147742821-1:1:1:1 for destination: queue://company.CD.Tomcat01.Repo.Request | org.apache.activemq.broker.region.AbstractRegion | ActiveMQ Transport: tcp:///127.0.0.1:49636@61616
2017-06-22 12:09:03,096 | DEBUG | queue://company.CD.Tomcat01.Repo.Request add sub: QueueSubscription: consumer=ID:39235aa-49635-1498147742821-1:1:1:1, destinations=0, dispatched=0, delivered=0, pending=0, dequeues: 0, dispatched: 0, inflight: 0 | org.apache.activemq.broker.region.Queue | ActiveMQ Transport: tcp:///127.0.0.1:49636@61616
2017-06-22 12:09:03,097 | DEBUG | queue://company.CD.Tomcat01.Repo.Request, subscriptions=2, memory=0%, size=0, pending=0 toPageIn: 0, Inflight: 0, pagedInMessages.size 0, pagedInPendingDispatch.size 0, enqueueCount: 0, dequeueCount: 0, memUsage:0 | org.apache.activemq.broker.region.Queue | Queue:company.CD.Tomcat01.Repo.Request
2017-06-22 12:09:03,097 | DEBUG | queue://company.CD.Tomcat01.Repo.Request, subscriptions=2, memory=0%, size=0, pending=0 toPageIn: 0, Inflight: 0, pagedInMessages.size 0, pagedInPendingDispatch.size 0, enqueueCount: 0, dequeueCount: 0, memUsage:0 | org.apache.activemq.broker.region.Queue | ActiveMQ Transport: tcp:///127.0.0.1:49636@61616
2017-06-22 12:09:03,105 | DEBUG | queue://company.CD.Tomcat01.Repo.Request, subscriptions=2, memory=0%, size=0, pending=0 toPageIn: 0, Inflight: 0, pagedInMessages.size 0, pagedInPendingDispatch.size 0, enqueueCount: 0, dequeueCount: 0, memUsage:0 | org.apache.activemq.broker.region.Queue | ActiveMQ Transport: tcp:///127.0.0.1:49636@61616
2017-06-22 12:09:03,114 | DEBUG | queue://company.CD.Tomcat01.Repo.Request, subscriptions=2, memory=0%, size=0, pending=0 toPageIn: 0, Inflight: 0, pagedInMessages.size 0, pagedInPendingDispatch.size 0, enqueueCount: 0, dequeueCount: 0, memUsage:0 | org.apache.activemq.broker.region.Queue | ActiveMQ Transport: tcp:///127.0.0.1:49636@61616
2017-06-22 12:09:03,114 | DEBUG | queue://company.CD.Tomcat01.Repo.Request, subscriptions=2, memory=0%, size=0, pending=0 toPageIn: 0, Inflight: 0, pagedInMessages.size 0, pagedInPendingDispatch.size 0, enqueueCount: 0, dequeueCount: 0, memUsage:0 | org.apache.activemq.broker.region.Queue | ActiveMQ Transport: tcp:///127.0.0.1:49636@61616
2017-06-22 12:09:03,114 | DEBUG | queue://company.CD.Tomcat01.Repo.Request, subscriptions=2, memory=0%, size=0, pending=0 toPageIn: 0, Inflight: 0, pagedInMessages.size 0, pagedInPendingDispatch.size 0, enqueueCount: 0, dequeueCount: 0, memUsage:0 | org.apache.activemq.broker.region.Queue | ActiveMQ Transport: tcp:///127.0.0.1:49636@61616
2017-06-22 12:09:03,114 | DEBUG | queue://company.CD.Tomcat01.Repo.Request, subscriptions=2, memory=0%, size=0, pending=0 toPageIn: 0, Inflight: 0, pagedInMessages.size 0, pagedInPendingDispatch.size 0, enqueueCount: 0, dequeueCount: 0, memUsage:0 | org.apache.activemq.broker.region.Queue | ActiveMQ Transport: tcp:///127.0.0.1:49636@61616
2017-06-22 12:09:03,115 | DEBUG | queue://company.CD.Tomcat01.Repo.Request, subscriptions=2, memory=0%, size=0, pending=0 toPageIn: 0, Inflight: 0, pagedInMessages.size 0, pagedInPendingDispatch.size 0, enqueueCount: 0, dequeueCount: 0, memUsage:0 | org.apache.activemq.broker.region.Queue | ActiveMQ Transport: tcp:///127.0.0.1:49636@61616
2017-06-22 12:09:03,115 | DEBUG | queue://company.CD.Tomcat01.Repo.Request, subscriptions=2, memory=0%, size=0, pending=0 toPageIn: 0, Inflight: 0, pagedInMessages.size 0, pagedInPendingDispatch.size 0, enqueueCount: 0, dequeueCount: 0, memUsage:0 | org.apache.activemq.broker.region.Queue | ActiveMQ Transport: tcp:///127.0.0.1:49636@61616
如果我们查看两个activemq日志之间的区别,
它显示队列订阅行正在打印一次或两次,然后在30秒的间隔后,到期时间开始并且循环继续
但是在第二个日志中,到期时间从未开始,并且每隔ms打印一次队列订阅行,并且日志会在几分钟内进入GB,因此会出现某种循环。
我们正在尝试对此进行调试,但如果有人有任何想法或建议,请通过。
感谢。
答案 0 :(得分:1)
发现问题,升级后的4.3.8版本现在有0为receivetimeout而不是早于-1等待它获取我们曾经使用的新消息,以及为什么它试图从代理获取消息(activemq) )在循环中并用那些导致CPU持续使用的调用轰炸它。
来自JmsDestinationAccessor类的代码片段。
protected Message receiveFromConsumer(MessageConsumer consumer, long timeout) throws JMSException {
if (timeout > 0) {
return consumer.receive(timeout);
}
else if (timeout < 0) {
return consumer.receiveNoWait();
}
else {
return consumer.receive();
}
}