Propagate thread context when using vertx EventBus #27709
-
I'm trying to get context propagation working when using event bus. I've created a simple flow following this guide https://quarkus.io/guides/reactive-event-bus. The code looks something like this:
SLF4J_MDC is a simple ThreadContextProvider implementation that I have registered in order to propagate the MDC values. I already tested this mechanism with regular async code and it worked, but not with eventBus. Endpoint works as expected, but the values I am trying to log are null. What is the right way to use context propagation in this scenario? Is it possible or is it not intended to be used in conjunction with event bus requests? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Take a look here - https://reactiverse.io/reactiverse-contextual-logging/ Contextual data is not propagated over the EventBus. In this case, it must be:
This process can be automated with EventBus interceptors:
|
Beta Was this translation helpful? Give feedback.
-
Hey @ashutoshk2206, I am trying to propagate MDC context to event bus consumers in Quarkus and I applied your solution above but it doesn't work for me. I am using slf4j as logging library which is not supported according to https://reactiverse.io/reactiverse-contextual-logging/#_supported_logging_libraries. Do you have any suggestions for that? Thank you. Event is produced like:
And on consumer side, I fill the MDC context from event message headers after that read the MDC and see that MDC context is set, but outside of the interceptor; the correlationId from MDC but it is logged as null:
|
Beta Was this translation helpful? Give feedback.
Take a look here - https://reactiverse.io/reactiverse-contextual-logging/
Contextual data is not propagated over the EventBus. In this case, it must be:
This process can be automated with EventBus interceptors: