ProcessorContext#header() is Empty



我们有kafka流应用程序。生产者在将 kafka 消息发送到 Kafka 流应用程序之前在 kafka 消息中添加标头。

在 Kafka 流媒体应用程序中,我们使用AbstractProcessorcontext.forward(null, Optional.of(event));将消息转发到另一个主题。

但是标题正在丢失。我希望标题从输入消息到输出主题。

ProcessorContext界面。headers()方法说返回当前输入记录的标头,但在我的情况下它是空的,尽管我发送带有标头的消息。

* Returns the headers of the current input record; could be null if it is not available
* @return the headers
*/
Headers headers();

Kafka Stream API 版本:2.3.1

如果使用处理器,则context.headers()process()调用,如果使用变压器,则transform()调用。

最新更新