When an Exception occurs in a route and isn't caught by an exception manager, the details of a route is displayed, helping a lot to know what could have gone wrong.
When the exception is caught and managed, how can it be possible to have the same kind of logs ?
I would prefer have something "callable" from the java part, for example in a Processor, but something in a dsl style could also do.
The route logging usually looks like :
Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId ProcessorId Processor Elapsed (ms)
[route1 ] [cxf_process ] [cxfrs://bean:myServer?bindingStyle=SimpleConsumer ] [ 60029]
[route1 ] [to55 ] [direct:validateAndRedirect ] [ 60029]
[route27 ] [setProperty37 ] [setProperty[operationName] ] [ 0]
[route27 ] [setProperty38 ] [setProperty[Country] ] [ 0]
[route27 ] [setProperty39 ] [setProperty[Language] ] [ 0]
[route27 ] [process25 ] [my.package.ExtractUserMailProcessor@535f9aac ] [ 0]
[route27 ] [enrich25 ] [enrich[direct:checkAccess] ] [ 0]
[route27 ] [recipientList1 ] [recipientList[simple{Simple: direct:${property.operationName}}] ] [ 60029]
[route28 ] [setHeader84 ] [setHeader[CamelCxfRsUsingHttpAPI] ] [ 0]
[route28 ] [setHeader85 ] [setHeader[CamelHttpPath] ] [ 0]
[route28 ] [setHeader86 ] [setHeader[CamelHttpMethod] ] [ 1]
[route28 ] [setHeader87 ] [setHeader[Content-Type] ] [ 0]
[route28 ] [enrich9 ] [enrich[direct:wsClient] ] [ 60029]
[route7 ] [to7 ] [cxfrs:bean:myClient ] [ 60027]
Exchange
---------------------------------------------------------------------------------------------------------------------------------------
...
Thx in advance,
François
This is the message history EIP pattern
That page details about this, and how you can access the history yourself. The org.apache.camel.util.MessageHelper#dumpMessageHistoryStacktrace
is what Camel uses itself to output that table you see above.
But as Konstantin wrote above, you get access to the history from Java code as follows
List<MessageHistory> list = exchange.getProperty(Exchange.MESSAGE_HISTORY, List.class);
After digging in the code, I found org.apache.camel.util.MessageHelper#dumpMessageHistoryStacktrace which should do what I want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With