Reputation: 21
We are facing an issue when executing retries on a Feign or Spring reactive WebClient HTTP client. We are setting the correlationId in the headers of the HTTP request (using an interceptor with Feign or a filter with Spring reactive WebClient), and everything works fine (we keep and get the correlationId from the SLF4J's MDC, but when the retry mechanism executes retry calls, because the retries are executing different threads we are losing the MDC context.
Because we don't have control over the Resilence4j thread pool we can not propagate the MDC context in these threads. Is there a way to propagate the MDC, create a custom TaskExecutor, and set a TaskDecorator in the Retryer thread pool?
Is this the expected behavior or am I missing something?
We are using:
Resilience4j version: 2.0.2 Spring Boot 3.0.2 Java version: 17
Thank you in advance
We tried setting the correlationId in the headers of the HTTP request (using an interceptor with Feign client or a Filter with Spring reactive WebClient.
We expect to keep and set MDC context and the correlationId between retries using resilence4j
Upvotes: 2
Views: 1008
Reputation: 9
I faced the same issue I resolved it by adding a maven dependency and adding custom properties in the application.yml to the circuitbreaker library. application.yml
resilience4j:
scheduled:
executor:
corePoolSize: 10
maxPoolSize: 2000
queueSize: 500
contextPropagators:
- io.github.resilience4j.test.TestContextPropagators.TestThreadLocalContextPropagatorWithHolder
Maven dependency is
<dependency>
<groupId>io.github.resilience4j</groupId>
<artifactId>resilience4j-test</artifactId>
<version>1.7.0</version>
</dependency>
Upvotes: 0