You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Jim Talbut <jt...@spudsoft.co.uk> on 2011/07/27 20:39:00 UTC

Correlation via ProducerTemplate

Hi,

For what I'm doing I need to correlate between an outer Exchange and one 
initiated via a ProducerTemplate.
At the moment I'm manually adding the correlation ID as a header when 
the message is sent and then pulling it out and setting it on the child 
Exchange.

This is nasty, and I'm thinking about replacing it with a custom 
ProducerTemplate that pulls the correlation ID from MDC and sets it on 
the child Exchange from the start.

Question: Is this something that belongs in Camel itself somewhere, 
either as a special type of ProducerTemplate or just as a small 
modification to the existing one?
Obviously if MDC logging isn't enabled the change wouldn't do anything.

I can't decide how I feel about asking for it to go in core.
The arguments against are that it's a pollution of the ProducerTemplate 
with 'logging' code; that it only works if MDC is enabled (and will 
silently, and confusingly, fail if it isn't).
The arguments for are that it would be damned handy and there's no other 
way to do it that will work behind the scenes in all cases (all cases 
where MDC is enabled!).

Jim