I'm currently facing a problem trying to handle an exception thrown in a sub
route invoked from a REST endpoint.

The following route context defines the sub-route:
        <routeContext id="routeContext"
                <route id="testInner" errorHandlerRef="noErrorHandler">
                        <from uri="direct:testInner" />
                        <transacted ref="jpaTransactionRequiredPolicy" />
                        <throwException exceptionType="java.lang.Exception" 
message="error" />

And the following REST context defines the endpoint that invokes the
sub-route via "direct":
        <restContext id="restContext"
                <rest path="/test">
                        <post id="testOuter" type="test.CSearchParameter">
                                                <log loggingLevel="ERROR" 
logName="test" message="Exception:
${property.CamelExceptionCaught}" />

                                        <log loggingLevel="WARN" logName="test" 
message="Before" />
                                        <to uri="direct:testInner" />
                                        <log loggingLevel="WARN" logName="test" 
message="After" />

Both are included in the same camel context.

What I want to achieve, is that the onException block of the REST endpoint
route "testOuter" handles the exception thrown in the route "testInner".

After invoking the above REST endpoint via SwaggerUI, the log file contains
the line with "Before", followed by an ERROR logged from an
TransactionErrorHandler, followed by a line stating the transaction
What I do not see, is the log line beginnging with "Exception:" from the
defined onException handler.

I already tried without the errorHandlerRef="noErrorHandler" on the inner
route, but the result is effectively the same. The ERROR and rollback log
line are written by a DefaultErrorHandler, but still no "Exception:" line
from the defined onException block.

What did I miss? How to handle the sub-route exception in the onException
handler of the REST route?

Btw., I'm currently using Camel 2.17.0, just in case it matters.


View this message in context: 
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to