Date: Fri, 29 Mar 2024 15:20:57 +0000 (UTC) Message-ID: <1548487995.6669.1711725657161@cwiki-he-fi.apache.org> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_6668_809424215.1711725657161" ------=_Part_6668_809424215.1711725657161 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
The Message History from the EIP patterns al= lows for analyzing and debugging the flow of messages in a loosely coupled = system.
Attaching a Message History to the message will provide a list of all ap= plications that the message passed through since its origination.
In Camel you can trace message flow using the Tracer, or access information using the Java API fro=
m U=
nitOfWork using the getTracedRouteNodes
method.
When Camel sends a message to an endpoint that endpoint information is s=
tored on the Exchange as=
a property with the key Exchange.TO_ENDPOINT
.
This property contains the last known endpoint the Exchange was sent to (it will be overridden whe=
n sending to new endpoint). Alternatively you can trace messages being sent=
using interceptors or =
the Event Notifier.
Available as of Camel 2.12
Message History is enabled by default from Camel 2.12. During routing Camel captures how =
the Exchange is routed, =
as a The information can be reached from Java code with: The Message Histor=
y can be enabled or disabled per Or from XML DSL with You can also do this per route. Then a route level configuration overrid=
es the If Message History=
is enabled, then Camel will leverage this information, when the Error Handler logs exhaus=
ted exceptions. Then in addition to the caused exception with its stacktrac=
e, you can see the message history; you may think this as a "route stacktra=
ce". And example is provided below: You can turn off logging message history from the Error Handler using From Camel 2.17 onwards the Error Handler do not log the message body/header deta=
ils anymore (to avoid logging sensitive message body details). You can turn=
on the old behavior. If you would like to use this EIP Pattern then please read the Getting Started, you may=
also find the Architect=
ure useful particularly the description of Endpoint and URIs. Then you could try out some of the Examples first before trying this pattern out.org.apache.camel.MessageHistory
entity that is stored on =
the Exchange. On the List<Messa=
geHistory> list =3D exchange.getProperty(Exchange.MESSAGE_HISTORY, List.=
class);
...
Enabling or dis=
abling message history
CamelContext
or per route=
. For example you can turn it off withcamelContext.=
setMessageHistory(false);
<camelCont=
ext messageHistory=3D"false" ...>
...
</camelContext>
CamelContext
level configuration.=
Route stack-trace in exceptions logged by error handler
2013-05-31 14=
:41:28,084 [ - seda://start] ERROR DefaultErrorHandler - Failed =
delivery for (MessageId: ID-davsclaus-air-lan-55446-1370004087263-0-1 on Ex=
changeId: ID-davsclaus-air-lan-55446-1370004087263-0-3). Exhausted after de=
livery attempt: 1 caught: java.lang.IllegalArgumentException: Forced to dum=
p message history
Message History
---------------------------------------------------------------------------=
------------------------------------------------------------
RouteId ProcessorId Processor =
Elapsed (ms)
[route1 ] [to1 ] [log:foo =
] [ 6]
[route1 ] [to2 ] [direct:bar =
] [ 102]
[route2 ] [to5 ] [log:bar =
] [ 1]
[route2 ] [delay2 ] [delay[{100}] =
] [ 100]
[route2 ] [to6 ] [mock:bar =
] [ 0]
[route1 ] [delay1 ] [delay[{300}] =
] [ 303]
[route1 ] [to3 ] [log:baz =
] [ 0]
[route1 ] [process1 ] [org.apache.camel.processor.Messa=
geHistoryDumpRoutingTest$1$1@6a53f9d8 ] [ 2]
Stacktrace
---------------------------------------------------------------------------=
------------------------------------------------------------
java.lang.IllegalArgumentException: Forced to dump message history
=09at org.apache.camel.processor.MessageHistoryDumpRoutingTest$1$1.process(=
MessageHistoryDumpRoutingTest.java:54)
=09at org.apache.camel.processor.DelegateSyncProcessor.process(DelegateSync=
Processor.java:63)
=09at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryE=
rrorHandler.java:388)
=09at org.apache.camel.processor.CamelInternalProcessor.process(CamelIntern=
alProcessor.java:189)
=09at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
=09at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
=09at org.apache.camel.processor.DelayProcessorSupport.process(DelayProcess=
orSupport.java:117)
=09at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryE=
rrorHandler.java:388)
=09at org.apache.camel.processor.CamelInternalProcessor.process(CamelIntern=
alProcessor.java:189)
=09at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
=09at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
=09at org.apache.camel.processor.CamelInternalProcessor.process(CamelIntern=
alProcessor.java:189)
=09at org.apache.camel.component.seda.SedaConsumer.sendToConsumers(SedaCons=
umer.java:293)
=09at org.apache.camel.component.seda.SedaConsumer.doRun(SedaConsumer.java:=
202)
=09at org.apache.camel.component.seda.SedaConsumer.run(SedaConsumer.java:14=
9)
=09at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.=
java:1145)
=09at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor=
.java:615)
=09at java.lang.Thread.run(Thread.java:722)
errorHandler(=
defaultErrorHandler().logExhaustedMessageHistory(false));
errorHandler(=
defaultErrorHandler().logExhaustedMessageBody(true));
Using This Pattern