You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Pushkar Deole <pd...@gmail.com> on 2020/06/01 06:59:52 UTC

Setting kafka headers in ProducerRecord

Hi All,

I need to use Kafka header in the ProducerRecord, however I see the
constructor to provide headers also need to mention the partition number. I
don't want the records to be distributed to available partitions based on
kafka's default mechanism and don't want to specify the partition by
myself. What is the option to provide headers without specifying the
partition?

Re: Setting kafka headers in ProducerRecord

Posted by "Matthias J. Sax" <mj...@apache.org>.
> I
>> don't want the records to be distributed to available partitions based on
>> kafka's default mechanism and don't want to specify the partition by
>> myself

This seems to be a contradiction. If you don't want either of them, what
do you want?

Btw: it is ok to pass `null` as partition; for this case, the producer
will use the configured `Partitioner` to compute the partition (what is
the default mechanism you claim not to want).


-Matthias

On 5/31/20 11:59 PM, Pushkar Deole wrote:
> Hi All,
> 
> I need to use Kafka header in the ProducerRecord, however I see the
> constructor to provide headers also need to mention the partition number. I
> don't want the records to be distributed to available partitions based on
> kafka's default mechanism and don't want to specify the partition by
> myself. What is the option to provide headers without specifying the
> partition?
>