Reputation: 2288
Does kafka allow adding custom headers to record metadata. Code suggests that it doesn't. Has anyone tried it ?
Upvotes: 3
Views: 2516
Reputation: 4375
apache-kafka has included supporting for custom headers since 0.11.0.0 version through KIP-82 - Add Record Headers.
For example, you can use this method:
public ProducerRecord(String topic,
Integer partition,
K key,
V value,
Iterable<Header> headers)
See also related questions:
Upvotes: 3
Reputation: 191844
Yes, the Java API has headers
public ProducerRecord(java.lang.String topic,
java.lang.Integer partition,
java.lang.Long timestamp,
K key,
V value,
java.lang.Iterable headers)
Creates a record with a specified timestamp to be sent to a specified topic and partition
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
Upvotes: 2