I've created the following JIRA: https://issues.apache.org/jira/browse/CAMEL-10624
________________________________ Von: Oliver Wulff <owu...@talend.com> Gesendet: Freitag, 16. Dezember 2016 13:44:08 An: users@camel.apache.org Betreff: AW: Custom MDC property per exchange Maybe something like <setMDC name="foo"><header name="bar"></setMDC> this will end up in the MDC property ("camel.foo") Within the MDCUnitOfWork, we could remove "camel.*". ________________________________ Von: Claus Ibsen <claus.ib...@gmail.com> Gesendet: Freitag, 16. Dezember 2016 12:30:33 An: users@camel.apache.org Betreff: Re: Custom MDC property per exchange Hmm its more a <setMDC name="foo"><header name="bar"/></setMDC> Where you can set a value from any expression, eg a simple <setMDC name="foo"><simple>${body.callMe}</simple></setMDC> The trick is to keep track of these custom MDC headers and ensure they are all cleared on thread context switches etc, which is what the MDCUnitOfWork ensures for the OOTB provided. On Fri, Dec 16, 2016 at 10:14 AM, Oliver Wulff <owu...@talend.com> wrote: > 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"> > > > WDYT? > > > Thanks > > Oli > > > > ________________________________ > Von: Claus Ibsen <claus.ib...@gmail.com> > Gesendet: Donnerstag, 15. Dezember 2016 20:13:45 > An: users@camel.apache.org > 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 <owu...@talend.com> 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 that? >> >> >> Thanks a lot for your feedback >> >> Oli > > > > -- > Claus Ibsen > ----------------- > http://davsclaus.com @davsclaus > Claus Ibsen (@davsclaus) riding the Apache Camel<http://davsclaus.com/> > davsclaus.com > A blog about Apache Camel, by Claus Ibsen, the leading contributor, and > author of the Camel in Action book. > > > Camel in Action 2: https://www.manning.com/ibsen2 > Manning | Camel in Action, Second Edition<https://www.manning.com/ibsen2> > www.manning.com<http://www.manning.com> > 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 ... > > -- Claus Ibsen ----------------- http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2