ThreadLocalAccessor- contract to assist with access to a
ContextAccessor- contract to assist with access to a
ContextRegistry- registry for instances of
ContextSnapshot- holder of contextual values, that provides methods to capture and to propagate.
In imperative code, e.g. Spring MVC controller, capture
ThreadLocalvalues into a
ContextSnapshot. After that use the snapshot to populate a Reactor
Contextwith the captured values, or to wrap a task (e.g.
Callable, etc) or an
Executorwith a decorator that restores
ThreadLocalvalues when the task executes.
In reactive code, e.g. Spring WebFlux controller, create a
Contextvalues. After that use the snapshot to restore
ThreadLocalvalues within a specific stage (operator) of the reactive chain.
Context values can originate from any context mechanism and propagate to any other, any
number of times. For example, a value in a
Reactor context may originate as a
ThreadLocal, and may yet become a
ThreadLocal again, and so on.
Generally, imperative code should interact with
ThreadLocal values as usual, and
likewise Reactor code should interact with the Reactor
Context as usual. The Context
Propagation library is not intended to replace those, but to assist with propagation when
crossing from one type of context to another, e.g. when imperative code invokes a Reactor
chain, or when a Reactor chain invokes an imperative component that expects
The library is not limited to context propagation from imperative to reactive. It can
assist in asynchronous scenarios to propagate
ThreadLocal values from one thread to
another. It can also propagate to any other type of context for which there is a