Is it possible to access message headers with Kafka Streams?

前端 未结 1 1399
你的背包
你的背包 2020-12-06 01:26

With the addition of Headers to the records (ProducerRecord & ConsumerRecord) in Kafka 0.11, is it possible to get these headers when processing a topic with Kafka Strea

相关标签:
1条回答
  • 2020-12-06 01:57

    Records headers are accessible since versions 2.0 of Streams API. (Cf. KIP-244 for details.)

    You can access record metadata via Processor API (ie, via transform(), transformValues(), or process()), by the given "context" object (cf. https://docs.confluent.io/current/streams/developer-guide/processor-api.html#accessing-processor-context).

    Prior to 2.0, the context only exposes topic, partition, offset, and timestamp---but not headers that are in fact dropped by Streams on read in those older versions.

    Metadata is not available at DSL level though. However, there is also work in progress to extend the DSL: https://cwiki.apache.org/confluence/display/KAFKA/KIP-159%3A+Introducing+Rich+functions+to+Streams

    0 讨论(0)
提交回复
热议问题