user300285
user300285

Reputation:

Stacktrace from Camel Context onException

I'm trying to retrieve the stacktrace from the onException handler in Apache Camel:

   <onException>
            <exception>java.lang.Exception</exception>
            <handled>
                <constant>true</constant>
            </handled>

            <setHeader headerName="exception">
                <simple>${exception}</simple>
            </setHeader>
   </onException>

However, the above only shows the exception rather than the entire stacktrace.

I understand that Camel stores the caught exception as a property on the Exchange with the key: Exchange.EXCEPTION_CAUGHT, but how can this be retrieved from the camel context routes file ?

Upvotes: 25

Views: 29016

Answers (1)

Claus Ibsen
Claus Ibsen

Reputation: 55525

Use exception.stacktrace to get the stacktrace. See the variables listed in the table at this page: http://camel.apache.org/simple

<simple>${exception.stacktrace}</simple>

There is also a ${exception.message} to refer to the exception message itself.

Upvotes: 40

Related Questions