0

Here is my route:

<camel:endpoint id="media.retrieve.jms.inout.queue" uri="myActiveMQ:queue:RetrieveDocument?concurrentConsumers=5&amp;replyTo=RetrieveDocument&amp;requestTimeout=30000&amp;disableTimeToLive=true"/>
<camel:endpoint id="media.retrieve.jms.error.queue" uri="myActiveMQ:queue:RetrieveDocument" />
<camel:endpoint id="media.retrieve.jms.processed.queue" uri="myActiveMQ:queue:RetrieveDocument" />

<camel:routeContext id="retrieveMedia">
    <camel:route id="INT_DP_016-Media" routePolicyRef="routePolicy">
        <camel:from uri="direct:retrieveDocument" />
        <camel:onException useOriginalMessage="true">
            <camel:exception>java.lang.Exception</camel:exception>
            <camel:handled>
                <camel:constant>false</camel:constant><!-- send exception back -->
            </camel:handled>
            <camel:process ref="errorHandler" />
            <camel:to uri="ref:media.retrieve.jms.error.queue" />
        </camel:onException>
        <camel:wireTap uri="ref:media.retrieve.jms.processed.queue"/>
        <camel:marshal ref="jaxbMedia" />
        <camel:setProperty propertyName="outputBody">
            <camel:simple resultType="java.lang.String">${body}</camel:simple>
        </camel:setProperty>
        <camel:setExchangePattern pattern="InOut"/>
        <camel:to uri="ref:media.retrieve.jms.inout.queue" />
        <camel:transacted />
        <camel:process ref="mediaProcessor" />
    </camel:route>
</camel:routeContext>

I receive exception (expected for my case) in my Processor (mediaProcessor) and after that should wait 20000 ms for Timeout (since sent Message wasn't received as I understand).

1) Can I immediately stop waiting and just process exception in my onException clause?

2) Why my timeout is 20 sec but not 30 sec as I set at Endpoint options?

UPDATE: Just want to clarify since it may be not clear where 20 sec timeout is raised. I have routePolicy where org.apache.camel.spi.RoutePolicy.onExchangeDone(Route, Exchange) method is invoked after 20 sec starting from the moment when my onException handler was processed:

 Caused by: org.apache.camel.ExchangeTimedOutException: The OUT message was not received within: 20000 millis due reply message with correlationID: Camel-ID-michael-desktop-45995-1384079313615-1-5 not received. Exchange[Message: <?xml version="1.0" encoding="UTF-8"?>...

Why route is not finished at Exception handler? Why system still think it has some undelivered messages?

4

1 回答 1

0

问题出在我的路线上,它有ExchangePattern=InOut但发生错误后,消息转到 ErrorQueue (ref:media.retrieve.jms.error.queue)并等待从未出现的回复。在为 OnException 子句设置ExchangePattern=InOnly后(即当消息出现在 ErrorQueue 上时)我会立即对错误做出反应,没有 20 秒的延迟,即 onException 应该是:

<camel:onException useOriginalMessage="true">
        <camel:exception>java.lang.Exception</camel:exception>
        <camel:handled>
            <camel:constant>false</camel:constant><!-- send exception back -->
        </camel:handled>
        <camel:process ref="errorHandler" />
        <camel:setExchangePattern pattern="InOnly"/><!--HERE IS A FIX-->
        <camel:to uri="ref:media.retrieve.jms.error.queue" />
    </camel:onException>
于 2013-11-10T14:37:11.853 回答