From the course: Complete Guide to Spring MVC

Unlock this course with a free trial

Join today to access over 24,600 courses taught by industry experts.

Context propagation

Context propagation

- [Instructor] Context Propagation. Context Propagation refers to the process of transferring context-specific information, so think like ThreadLocal values, across different threads in an asynchronous application. In Spring MVC, where asynchronous processing is common, propagating ThreadLocal values like user session data or locale settings across threads can be challenging. This is because ThreadLocal is tied to the thread it was created on and doesn't naturally transfer across thread boundaries. So that brings in something called a Micrometer Context Propagation. The Micrometer Context Propagation library simplifies this process by integrating with various asynchronous programming models. When used with Reactive types like Mono or Flux in Spring MVC, it ensures that ThreadLocal values are propagated automatically into the Reactor Context, allowing them to be accessed seamlessly in asynchronous workflows. So how does Context Propagation work in Spring MVC? Let's start with…

Contents