Kafka - Inspecting outgoing kafka messages. #2300
-
Hi, we are currently trying to automatically propagate an incoming HTTP Header in Quarkus as a kafka header in our microservice architecture for testing purposes. Let's call that header "X-Testing-Data" for now. My current plan is to use channel decorators to do the following steps:
Unfortunately, I am currently already failing with step 1. Outgoing messages seem to have varying formats, so to figure out where the Kafka Headers inside the message are, I would have to reimplement a subset of this function here: But checking for the existence of certain classes inside of the message seems very likely to break in future updates. I did also not find anything about this in the API documentation. Am I missing something? I assume adding/removing/manipulating key/value/header is the goal of channel decorators, but without a way to inspect the existing message, they seem unusable to me... What I would have expected to see is a function that transforms any given message into a ProducerRecord or similar. Hope someone can explain what I am failing to understand. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
If you want to propagate HTTP headers the best option is to use OutgoingInterceptor and add In Quarkus we recommend using You can write a ServerRequestFilter to inject headers to be propagated to the I'll write a section with examples about this in the Quarkus Kafka guide. |
Beta Was this translation helpful? Give feedback.
If you want to propagate HTTP headers the best option is to use OutgoingInterceptor and add
OutgoingKafkaRecordMetadata
to your outgoing message.In Quarkus we recommend using
ContextLocals
to propagate contextual information between HTTP and RM producer channels.You can write a ServerRequestFilter to inject headers to be propagated to the
ContextLocals
and retrieve them in your OutgoingInterceptor. In normal use cases, the context is preserved.I'll write a section with examples about this in the Quarkus Kafka guide.