Skip to content

Add a context-propagation SPI to carry caller context #1481

Description

@mcruzdev

Context

Currently the API allows us to provide a SPI implementation to decorate the outbound HTTP request via HttpRequestDecorator implementation.

The problem

HttpExecutor dispatches the request build + send onto WorkflowApplication.executorService(), and a workflow may hop threads several times befora a task runs. By example, with you add a wait task first and use a http task after it is impossible for HttpRequestDecorator to read any thread-bound context that only exists on the thread that called WorkflowInstance.start()

2026-06-23 16:06:50,158 INFO  [io.quarkiverse.flow.tracing.TraceLoggerExecutionListener] (executor-thread-1) Task 'wait-0' started at 2026-06-23T16:06:50.158432-03:00 pos=do/0/wait-0
2026-06-23 16:06:53,162 INFO  [io.quarkiverse.flow.tracing.TraceLoggerExecutionListener] (ForkJoinPool.commonPool-delayScheduler) Task 'wait-0' completed at 2026-06-23T16:06:53.162152-03:00 output={}
2026-06-23 16:06:53,164 INFO  [io.quarkiverse.flow.tracing.TraceLoggerExecutionListener] (ForkJoinPool.commonPool-delayScheduler) Task 'http-1' started at 2026-06-23T16:06:53.164578-03:00 pos=do/1/http-1

FAIL: The HttpRequestDecorator does not have access to the thread context (it executes in ForkJoinPool.commonPool-delayScheduler) the caller one is the executor-thread-1.

Details: When the http task is the first one it is called with the same thread that called the WorkflowApplication.start():

2026-06-23 16:17:29,312 INFO  [io.quarkiverse.flow.tracing.TraceLoggerExecutionListener] (executor-thread-1) Workflow name=backend-call instanceId=01KVTYMTX84Y5W37DKED7ZE637 started at 2026-06-23T16:17:29.311957-03:00 input={}
2026-06-23 16:17:29,313 INFO  [io.quarkiverse.flow.tracing.TraceLoggerExecutionListener] (executor-thread-1) Task 'http-0' started at 2026-06-23T16:17:29.313316-03:00 pos=do/0/http-0

OK: The HttpRequestDecorator does have access to the thread context and be able to run the tasks with the captured context.

Proposal

A SPI in impl/core to allow us to capture the context of the caller thread.

Metadata

Metadata

Labels

No labels
No labels

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions