Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stacktrace from Camel Context onException

Tags:

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 ?

like image 813
David Wadge Avatar asked Jan 23 '12 12:01

David Wadge


People also ask

How to handle Exceptions in apache Camel?

Using onException to handle known exceptions is a very powerful feature in Camel. You can mark the exception as being handled with the handle DSL, so the caller will not receive the caused exception as a response.

What is Exchange in camel?

An Exchange is the message container holding the information during the entire routing of a Message received by a Consumer . During processing down the Processor chain, the Exchange provides access to the current (not the original) request and response Message messages.

What is Apache Camel?

Apache Camel ™ is a versatile open-source integration framework based on known Enterprise Integration Patterns. Camel empowers you to define routing and mediation rules in a variety of domain-specific languages (DSL, such as Java, XML, Groovy, Kotlin, and YAML).


1 Answers

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.

like image 72
Claus Ibsen Avatar answered Sep 19 '22 11:09

Claus Ibsen