camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Wulff <>
Subject AW: Custom MDC property per exchange
Date Fri, 16 Dec 2016 09:14:14 GMT
Hi Claus

Thanks for the feedback. I've read this as well but I got the opinion that it's not a fit
for me. As far as I understand from the interface UnitOfWork it looks to me to allow only
a hook before the route starts and after. I'm more looking for an option where during processing
time to add an MDC value whose value is read from the body.

I also think we should have an easier option instead of extending MDCUnitOfWork.

Wouldn't it be worth a feature request to provide an option to store a header also as an MDC
value. Something like:

<setHeader headerName="myHeader" storeMDC="true">




Von: Claus Ibsen <>
Gesendet: Donnerstag, 15. Dezember 2016 20:13:45
Betreff: Re: Custom MDC property per exchange

You would need to create a custom MDC unit of work. You may be able to
extend the existing MDCUnitOfWork from camel-core. And then there is a
UnitOfWorkFactory you need to create and setup which creates your
custom one.

And yes you need to cleanup stuff with thread context switches and
whatnot, see how the existing does that, and you can do similar thing.

On Thu, Dec 15, 2016 at 6:50 PM, Oliver Wulff <> wrote:
> Hi there
> Camel has already support for MDC logging. I also saw some discussion about adding static(!)
MDC values when the context starts. I'd like to enhance it and add some application specific
context information to every new exchange like. First I parse the message and set some headers
but would also like to add the header to the MDC like:
> MDC.put("AppMsgId", headers.get("AppMsgId"))
> Is there some out-of-the-box support or do I have to create a custom bean to handle that?
> Is there anything I have to consider like cleaning the MDC's finally or will Camel handle
> Thanks a lot for your feedback
> Oli

Claus Ibsen
----------------- @davsclaus
Claus Ibsen (@davsclaus) riding the Apache Camel<>
A blog about Apache Camel, by Claus Ibsen, the leading contributor, and author of the Camel
in Action book.

Camel in Action 2:
Manning | Camel in Action, Second Edition<>
Apache Camel is a Java library that lets you implement the standard enterprise integration
patterns in a few lines of code. With a concise but sophisticated DSL, you ...

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message