Interface CamelMDCService

All Superinterfaces:
AutoCloseable, CamelContextAware, HasCamelContext, Service

public interface CamelMDCService extends Service, CamelContextAware
SPI that plugs a Mapped Diagnostic Context (MDC) propagation implementation into Camel's exchange processing pipeline.

SLF4J's MDC is thread-local, which means MDC values set on the originating thread are not automatically visible on continuation threads used by Camel's async routing engine. Implementations of this service are responsible for capturing the current MDC state when an exchange begins processing and restoring it on each continuation thread, so that log entries produced across async boundaries carry the same contextual key-value pairs (e.g., camel.exchangeId, camel.routeId, custom breadcrumb values).

Camel discovers the implementation via the service registry; the default implementation is MDCService in camel-mdc. The CamelContext starts and stops this service as part of its normal lifecycle.

See MDC Logging in the Camel user manual.

Since:
4.15