获得TimeOut进行交换后,Camel停止响应

时间:2014-07-08 08:05:26

标签: java apache-camel activemq

我在ActiveMQ之间路由Camel个消息在两个其他组件之间。 当Camel抛出ExchangeTimedOutException时,它没有响应来自相应客户端的其他请求。发生这种情况时我应该重启骆驼! 为什么?以及如何解决这个问题以便继续工作。

我的路线:

// ----<Exception Handler>----
onException(Exception.class).to("activemqException:queue:Q.SException");

// ----<the Route>----
from("activemq:queue:Q.S")
.threads(2, 20)
.inOut("activemq2:queue:Q.DB?requestTimeout=60s");

和TimeOut的stackTrace:

2014-07-08 11:23:40.098 [WARN ] TemporaryQueueReplyManager(Camel (camel-1) thread #38 - JmsReplyManagerTimeoutChecker[Q.DB]):126 - Timeout occurred after 60000 millis waiting for reply message with correlationID [ce4a53fd7821480fbe482717728063f2]. Setting ExchangeTimedOutException on (MessageId: queue_Q.S_ID_S-Win2008R2-1732-635404151223100728-1_26_1_2_1 on ExchangeId: ID-localhost-localdomain-58884-1404800138167-0-80) and continue routing.
2014-07-08 11:23:40.105 [ERROR] DefaultErrorHandler(Camel (camel-1) thread #38 - JmsReplyManagerTimeoutChecker[Q.DB]):161 - Failed delivery for (MessageId: queue_Q.S_ID_S-Win2008R2-1732-635404151223100728-1_26_1_2_1 on ExchangeId: ID-localhost-localdomain-58884-1404800138167-0-80). Exhausted after delivery attempt: 1 caught: org.apache.camel.ExchangeTimedOutException: The OUT message was not received within: 60000 millis due reply message with correlationID: ce4a53fd7821480fbe482717728063f2 not received. Exchange[JmsMessage[JmsMessageID: ID:S-Win2008R2-1732-635404151223100728-1:26:1:2:1]]. Processed by failure processor: FatalFallbackErrorHandler[Channel[sendTo(Endpoint[activemqException://queue:Q.SException])]]

Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId              ProcessorId          Processor                                                              Elapsed (ms)
[route7            ] [route7            ] [activemq://queue:Q.S                                               ] [     60205]
[route7            ] [threads7          ] [threads                                                            ] [     60205]
[null              ] [to2               ] [log:ir.sy.S.SFileLogger?level=INFO&showAll=true                    ] [         1]
[null              ] [to3               ] [log:ir.sy.S.SConsoleLogger?level=INFO&showAll=true                 ] [         0]
[route7            ] [to10              ] [activemq2:queue:Q.DB?requestTimeout=60s                            ] [     60205]
[null              ] [to2               ] [log:ir.sy.S.SFileLogger?level=INFO&showAll=true                    ] [         1]
[null              ] [to3               ] [log:ir.sy.S.SConsoleLogger?level=INFO&showAll=true                 ] [         0]
[null              ] [to1               ] [activemqException:queue:Q.SException                               ] [         5]

Exchange
---------------------------------------------------------------------------------------------------------------------------------------
Exchange[
    Id                  ID-localhost-localdomain-58884-1404800138167-0-80
    ExchangePattern     InOut
    Headers             {breadcrumbId=ID:S-Win2008R2-1732-635404151223100728-1:26:1:2:1, CamelRedelivered=false, CamelRedeliveryCounter=0, JMSCorrelationID=ce4a53fd7821480fbe482717728063f2, JMSDeliveryMode=2, JMSDestination=queue://Q.S, JMSExpiration=0, JMSMessageID=ID:S-Win2008R2-1732-635404151223100728-1:26:1:2:1, JMSPriority=4, JMSRedelivered=false, JMSReplyTo=queue://Q.j, JMSTimestamp=1404802587776, JMSType=null, JMSXGroupID=null, JMSXUserID=null, Title=TestTrades}
    BodyType            java.util.HashMap
    Body                {...}
]

Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
org.apache.camel.ExchangeTimedOutException: The OUT message was not received within: 60000 millis due reply message with correlationID: ce4a53fd7821480fbe482717728063f2 not received. Exchange[JmsMessage[JmsMessageID: ID:S-Win2008R2-1732-635404151223100728-1:26:1:2:1]]
    at org.apache.camel.component.jms.reply.ReplyManagerSupport.processReply(ReplyManagerSupport.java:133) [camel-jms-2.13.0.jar:2.13.0]
    at org.apache.camel.component.jms.reply.TemporaryQueueReplyHandler.onTimeout(TemporaryQueueReplyHandler.java:61) [camel-jms-2.13.0.jar:2.13.0]
    at org.apache.camel.component.jms.reply.CorrelationTimeoutMap.onEviction(CorrelationTimeoutMap.java:53) [camel-jms-2.13.0.jar:2.13.0]
    at org.apache.camel.component.jms.reply.CorrelationTimeoutMap.onEviction(CorrelationTimeoutMap.java:30) [camel-jms-2.13.0.jar:2.13.0]
    at org.apache.camel.support.DefaultTimeoutMap.purge(DefaultTimeoutMap.java:212) [camel-core-2.13.0.jar:2.13.0]
    at org.apache.camel.support.DefaultTimeoutMap.run(DefaultTimeoutMap.java:162) [camel-core-2.13.0.jar:2.13.0]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [?:1.7.0_25]
    at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351) [?:1.7.0_25]
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178) [?:1.7.0_25]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178) [?:1.7.0_25]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.7.0_25]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [?:1.7.0_25]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [?:1.7.0_25]
    at java.lang.Thread.run(Thread.java:724) [?:1.7.0_25]
2014-07-08 11:24:01.002 [WARN ] TemporaryQueueReplyManager(Camel (camel-1) thread #42 - JmsReplyManagerTimeoutChecker[Q.SException]):126 - Timeout occurred after 20000 millis waiting for reply message with correlationID [ce4a53fd7821480fbe482717728063f2]. Setting ExchangeTimedOutException on (MessageId: queue_Q.S_ID_S-Win2008R2-1732-635404151223100728-1_26_1_2_1 on ExchangeId: ID-localhost-localdomain-58884-1404800138167-0-80) and continue routing.
2014-07-08 11:24:01.003 [ERROR] FatalFallbackErrorHandler(Camel (camel-1) thread #42 - JmsReplyManagerTimeoutChecker[Q.SException]):53 - Exception occurred while trying to handle previously thrown exception on exchangeId: ID-localhost-localdomain-58884-1404800138167-0-80 using: [Channel[sendTo(Endpoint[activemqException://queue:Q.SException])]]. The previous and the new exception will be logged in the following.
2014-07-08 11:24:01.004 [ERROR] FatalFallbackErrorHandler(Camel (camel-1) thread #42 - JmsReplyManagerTimeoutChecker[Q.SException]):54 - \--> Previous exception on exchangeId: ID-localhost-localdomain-58884-1404800138167-0-80
org.apache.camel.ExchangeTimedOutException: The OUT message was not received within: 60000 millis due reply message with correlationID: ce4a53fd7821480fbe482717728063f2 not received. Exchange[JmsMessage[JmsMessageID: ID:S-Win2008R2-1732-635404151223100728-1:26:1:2:1]]
    at org.apache.camel.component.jms.reply.ReplyManagerSupport.processReply(ReplyManagerSupport.java:133) [camel-jms-2.13.0.jar:2.13.0]
    at org.apache.camel.component.jms.reply.TemporaryQueueReplyHandler.onTimeout(TemporaryQueueReplyHandler.java:61) [camel-jms-2.13.0.jar:2.13.0]
    at org.apache.camel.component.jms.reply.CorrelationTimeoutMap.onEviction(CorrelationTimeoutMap.java:53) [camel-jms-2.13.0.jar:2.13.0]
    at org.apache.camel.component.jms.reply.CorrelationTimeoutMap.onEviction(CorrelationTimeoutMap.java:30) [camel-jms-2.13.0.jar:2.13.0]
    at org.apache.camel.support.DefaultTimeoutMap.purge(DefaultTimeoutMap.java:212) [camel-core-2.13.0.jar:2.13.0]
    at org.apache.camel.support.DefaultTimeoutMap.run(DefaultTimeoutMap.java:162) [camel-core-2.13.0.jar:2.13.0]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [?:1.7.0_25]
    at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351) [?:1.7.0_25]
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178) [?:1.7.0_25]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178) [?:1.7.0_25]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.7.0_25]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [?:1.7.0_25]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [?:1.7.0_25]
    at java.lang.Thread.run(Thread.java:724) [?:1.7.0_25]
2014-07-08 11:24:01.005 [ERROR] FatalFallbackErrorHandler(Camel (camel-1) thread #42 - JmsReplyManagerTimeoutChecker[Q.SException]):55 - \--> New exception on exchangeId: ID-localhost-localdomain-58884-1404800138167-0-80
org.apache.camel.ExchangeTimedOutException: The OUT message was not received within: 20000 millis due reply message with correlationID: ce4a53fd7821480fbe482717728063f2 not received. Exchange[JmsMessage[JmsMessageID: ID:S-Win2008R2-1732-635404151223100728-1:26:1:2:1]]
    at org.apache.camel.component.jms.reply.ReplyManagerSupport.processReply(ReplyManagerSupport.java:133) [camel-jms-2.13.0.jar:2.13.0]
    at org.apache.camel.component.jms.reply.TemporaryQueueReplyHandler.onTimeout(TemporaryQueueReplyHandler.java:61) [camel-jms-2.13.0.jar:2.13.0]
    at org.apache.camel.component.jms.reply.CorrelationTimeoutMap.onEviction(CorrelationTimeoutMap.java:53) [camel-jms-2.13.0.jar:2.13.0]
    at org.apache.camel.component.jms.reply.CorrelationTimeoutMap.onEviction(CorrelationTimeoutMap.java:30) [camel-jms-2.13.0.jar:2.13.0]
    at org.apache.camel.support.DefaultTimeoutMap.purge(DefaultTimeoutMap.java:212) [camel-core-2.13.0.jar:2.13.0]
    at org.apache.camel.support.DefaultTimeoutMap.run(DefaultTimeoutMap.java:162) [camel-core-2.13.0.jar:2.13.0]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [?:1.7.0_25]
    at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351) [?:1.7.0_25]
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178) [?:1.7.0_25]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178) [?:1.7.0_25]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.7.0_25]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [?:1.7.0_25]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [?:1.7.0_25]
    at java.lang.Thread.run(Thread.java:724) [?:1.7.0_25]
2014-07-08 11:24:01.007 [WARN ] EndpointMessageListener(Camel (camel-1) thread #6 - JmsConsumer[Q.S]):136 - Execution of JMS message listener failed. Caused by: [org.apache.camel.RuntimeCamelException - org.apache.camel.ExchangeTimedOutException: The OUT message was not received within: 20000 millis due reply message with correlationID: ce4a53fd7821480fbe482717728063f2 not received. Exchange[JmsMessage[JmsMessageID: ID:S-Win2008R2-1732-635404151223100728-1:26:1:2:1]]]
org.apache.camel.RuntimeCamelException: org.apache.camel.ExchangeTimedOutException: The OUT message was not received within: 20000 millis due reply message with correlationID: ce4a53fd7821480fbe482717728063f2 not received. Exchange[JmsMessage[JmsMessageID: ID:S-Win2008R2-1732-635404151223100728-1:26:1:2:1]]
    at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1363) ~[camel-core-2.13.0.jar:2.13.0]
    at org.apache.camel.component.jms.EndpointMessageListener$EndpointMessageListenerAsyncCallback.done(EndpointMessageListener.java:186) ~[camel-jms-2.13.0.jar:2.13.0]
    at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:107) ~[camel-jms-2.13.0.jar:2.13.0]
    at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:562) ~[spring-jms-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:500) [spring-jms-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:468) [spring-jms-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:325) [spring-jms-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:263) [spring-jms-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1096) [spring-jms-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1088) [spring-jms-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:985) [spring-jms-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [?:1.7.0_25]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [?:1.7.0_25]
    at java.lang.Thread.run(Thread.java:724) [?:1.7.0_25]
Caused by: org.apache.camel.ExchangeTimedOutException: The OUT message was not received within: 20000 millis due reply message with correlationID: ce4a53fd7821480fbe482717728063f2 not received. Exchange[JmsMessage[JmsMessageID: ID:S-Win2008R2-1732-635404151223100728-1:26:1:2:1]]
    at org.apache.camel.component.jms.reply.ReplyManagerSupport.processReply(ReplyManagerSupport.java:133) ~[camel-jms-2.13.0.jar:2.13.0]
    at org.apache.camel.component.jms.reply.TemporaryQueueReplyHandler.onTimeout(TemporaryQueueReplyHandler.java:61) ~[camel-jms-2.13.0.jar:2.13.0]
    at org.apache.camel.component.jms.reply.CorrelationTimeoutMap.onEviction(CorrelationTimeoutMap.java:53) ~[camel-jms-2.13.0.jar:2.13.0]
    at org.apache.camel.component.jms.reply.CorrelationTimeoutMap.onEviction(CorrelationTimeoutMap.java:30) ~[camel-jms-2.13.0.jar:2.13.0]
    at org.apache.camel.support.DefaultTimeoutMap.purge(DefaultTimeoutMap.java:212) ~[camel-core-2.13.0.jar:2.13.0]
    at org.apache.camel.support.DefaultTimeoutMap.run(DefaultTimeoutMap.java:162) ~[camel-core-2.13.0.jar:2.13.0]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) ~[?:1.7.0_25]
    at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351) ~[?:1.7.0_25]
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178) ~[?:1.7.0_25]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178) ~[?:1.7.0_25]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) ~[?:1.7.0_25]
    ... 3 more

1 个答案:

答案 0 :(得分:0)

我认为你的问题与5月份的问题相同(Apache Camel: Reply received for unknown correlationID),我的答案也适用于此:当你使用多个并行生产者进行InOut消息传递时,你需要做一些事情来分开回应,以便每个回复到生产者的目的。

threads(2,20)永远无法与InOut一起使用,因为每条路线都需要一些方法来区分其响应。