# Context Propagator java SDK

**URL:** <https://community.temporal.io/t/context-propagator-java-sdk/2189>\
**Category:** Community Support\
**Tags:** java-sdk\
**Created:** [May 20, 2021, 7:17am UTC](https://community.temporal.io/t/context-propagator-java-sdk/2189 "2021-05-20T07:17:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kcm](https://avatars.discourse-cdn.com/v4/letter/k/f1d935/32.png) [@kcm](https://community.temporal.io/u/kcm)\
**Post date:** [May 20, 2021, 7:17am UTC](https://community.temporal.io/t/context-propagator-java-sdk/2189/1 "2021-05-20T07:17:39Z")

</div>

What is the use of Context Propagator and how to implement it ? using java SDK.

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [May 20, 2021, 3:28pm UTC](https://community.temporal.io/t/context-propagator-java-sdk/2189/2 "2021-05-20T15:28:43Z")

</div>

We don’t have a sample for the ContextPropagator. [Here is](https://github.com/temporalio/sdk-java/blob/611de11785dfe7ec7341675cff0238a608fe9ced/temporal-sdk/src/test/java/io/temporal/internal/testing/WorkflowTestingTest.java#L878) a test implementation of one.

---

<div class="post-metadata">

**Author:** ![yodkorz](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/yodkorz/32/905_2.png) [@yodkorz](https://community.temporal.io/u/yodkorz)\
**Post date:** [May 25, 2021, 8:29pm UTC](https://community.temporal.io/t/context-propagator-java-sdk/2189/3 "2021-05-25T20:29:16Z")

</div>

Is there a way for the workflow method to get the context object? The test leverages slfj4.MDC but I’m concerned about making some values available to logging as well as cleaning up the threadpool storage.

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [May 26, 2021, 4:03am UTC](https://community.temporal.io/t/context-propagator-java-sdk/2189/4 "2021-05-26T04:03:12Z")

</div>

Use [WorkflowThreadLocal](https://github.com/temporalio/sdk-java/blob/master/temporal-sdk/src/main/java/io/temporal/workflow/WorkflowThreadLocal.java) or [WorkflowLocal](https://github.com/temporalio/sdk-java/blob/master/temporal-sdk/src/main/java/io/temporal/workflow/WorkflowLocal.java) to pass values to workflows from the context propagator.

---

<div class="post-metadata">

**Author:** ![AndreaColombo](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@AndreaColombo](https://community.temporal.io/u/AndreaColombo)\
**Post date:** [April 17, 2023, 2:28pm UTC](https://community.temporal.io/t/context-propagator-java-sdk/2189/5 "2023-04-17T14:28:45Z")

</div>

Hi Maxim,  
this thread is old, nevertheless I have a question related to this specific test.

In this test MDC is used to pass a value with key “test” to the workflow using contxt propagators.  
Let’s say instead that we have the same contxt propagator, but we want to set the value of the key “test” within the workflow.  
Can we expect to have the value set on the client side (i.e. retrieving it with MDC.get)?  
If not, there is any other way to “propagate” key/values pairs from a workflow (or activity) back to the client?

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [April 17, 2023, 5:24pm UTC](https://community.temporal.io/t/context-propagator-java-sdk/2189/6 "2023-04-17T17:24:54Z")

</div>

Currently, the workflow and activity results don’t support header fields used to propagate context information. Please file an issue to get them added.

---

<div class="post-metadata">

**Author:** ![antonio.perez](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/antonio.perez/32/2417_2.png) [@antonio.perez](https://community.temporal.io/u/antonio.perez)\
**Post date:** [June 26, 2023, 2:09pm UTC](https://community.temporal.io/t/context-propagator-java-sdk/2189/7 "2023-06-26T14:09:33Z")

</div>

Linking the issue [Header propagation on activity/workflow results · Issue #4179 · temporalio/temporal · GitHub](https://github.com/temporalio/temporal/issues/4179)
