【发布时间】:2020-02-25 06:05:54
【问题描述】:
kafka 是否允许添加自定义标头来记录元数据。代码表明它没有。有人试过吗?
【问题讨论】:
-
这能回答你的问题吗? Adding Custom Headers in Kafka Message
标签: apache-kafka
kafka 是否允许添加自定义标头来记录元数据。代码表明它没有。有人试过吗?
【问题讨论】:
标签: apache-kafka
apache-kafka 从 0.11.0.0 版本到 KIP-82 - Add Record Headers 包括对自定义标头的支持。
例如,你可以使用这个method:
public ProducerRecord(String topic,
Integer partition,
K key,
V value,
Iterable<Header> headers)
另请参阅相关问题:
【讨论】:
是的,the Java API 有标题
public ProducerRecord(java.lang.String topic,
java.lang.Integer partition,
java.lang.Long timestamp,
K key,
V value,
java.lang.Iterable headers)
创建具有指定时间戳的记录,发送到指定主题和分区
Parameters:
topic - The topic the record will be appended to
partition - The partition to which the record should be sent
timestamp - The timestamp of the record, in milliseconds since epoch. If null, the producer will assign the timestamp using System.currentTimeMillis().
key - The key that will be included in the record
value - The record contents
headers - the headers that will be included in the record
【讨论】: