Hi Camel users

I have a Camel workflow that spans two asynchronous transacted routes
divided by queues. The second one is calling a direct-route that calls
another direct-route (see below for detailed example Spring-DSL structure).
The reason for the direct routes is that the processing of them must be
synchronous.

The happy path works fine, now I try to get the error handling done:
1) I would like to generally send messages with errors to a custom error
queue and append the error message in a message header (to understand what
was happening).
2) I would like to retry the processing of the two direct routes as a whole
if an error occurs.
3) If the direct-route processing fails 3 times, send it to an error queue
(like #1).
4) If a specific exception is thrown in the direct routes, I would like to
send it directly (without retry) to an error queue (like #1).

I achieved number 2 as a first step by using the "NoErrorHandler" as
suggested on this page:
http://camel.apache.org/how-do-i-retry-processing-a-message-from-a-certain-point-back-or-an-entire-route.html

If an error occurs, the whole two direct routes are reprocessed and if a
retry succeeds, everything is ok.

However, if all retries fail, the default error handler kicks in and since
I'm in transacted routes, this is backed by the Spring
JmsTransactionManager. Therefore the message is moved to the correspondent
DLQ.

Problem 1: This is not the queue I would like to send errors to.
Problem 2: I cannot add the exception information to the message header.
(OK, I could probably do this in an onRedeliveryProcessor, but I expected
something like "setHeader").

Notice: In an OnException-Block I can easily add the Exception to the
message header as well as I can send the message to a custom error queue.

Questions:
1. Can I easily add exception information to a message processed by the
Camel errorhandler?
2. Can I easily send a message processed by the Camel errorhandler to a
custom error queue?

If one of the two questions above is NO
3. Do I therefore need to implement onException-Routes and catch all errors
with these "custom-error-routes" to accomplish these requirements?

I understand that onException-Blocks are "custom handlers" for special
things that should not be treated by the standard errorhandler. But it
seems to me that the standard errorhandler is almost useless for my
requirements. Am I totally wrong?

Thanks for your answers
Stephan




Example route structure in Spring DSL:

<route id="import" errorHandlerRef="transactionErrorHandler">
    <from uri="activemq:queue:queue.import"/>
    <transacted/>
    <log message="[IMPORT] do stuff"/>
    <to uri="activemq:queue:queue.groups"/>
</route>

<route id="groups" errorHandlerRef="transactionErrorHandler">
    <from uri="activemq:queue:queue.groups"/>
    <transacted/>
    <log message="[GROUPS] do stuff"/>
    <to uri="direct:check.write.bo"/>
</route>

<route id="check" errorHandlerRef="noErrorHandler">
    <from uri="direct:check.write.bo"/>
    <bean ref="mockBean" method="ruleEngineCheckBoUpdates" />
    <choice>
    <when>
        <simple>${header.RuleEngine} == 'OK'</simple>
        <log message="[CHECK OK] do stuff"/>
        <to uri="direct:write.data"/>
        <to uri="mock:queue.archiver"/>
    </when>
    <otherwise>
        <log message="[CHECK NOK] do stuff"/>
        <to uri="mock:queue.error"/>
    </otherwise>
    </choice>
</route>

<route id="write" errorHandlerRef="noErrorHandler">
    <from uri="direct:write.data"/>
    <log message="[WRITE] do stuff"/>
</route>

Reply via email to