来自Camel Context onException的Stacktrace

Dav*_*dge 22 apache-camel

我正在尝试从Apache Camel中的onException处理程序检索stacktrace:

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

            <setHeader headerName="exception">
                <simple>${exception}</simple>
            </setHeader>
   </onException>
Run Code Online (Sandbox Code Playgroud)

但是,上面只显示异常而不是整个堆栈跟踪.

我知道Camel将捕获的异常作为Exchange上的属性存储,密钥为:Exchange.EXCEPTION_CAUGHT,但是如何从camel context routes文件中检索它?

Cla*_*sen 30

使用exception.stacktrace来获取堆栈跟踪.请参阅本页表格中列出的变量:http://camel.apache.org/simple

<simple>${exception.stacktrace}</simple>
Run Code Online (Sandbox Code Playgroud)

还有$ {exception.message}来引用异常消息本身.