Search code examples
javascriptnode.jsapache-kafkalibrdkafka

Is there a way we can pass tenantId with header while producing the messages with node-rdkafka library?


I am using node-rdkafka library for one of my application. So I have one requirement to pass tenantId with header while producing messages. I checked the documentation but not getting what I required or may be I am missing something. So is there a way we can pass tenantid with headers while producing messages with node-rdkafka library?


Solution

  • Support for message headers was added in node-rdkafka 2.7.

    For example:

    var headers = [
      { header: "header value" }
    ]
    producer.produce(topicName, partition, value, key, Date.now(), "", headers);
    

    See https://github.com/Blizzard/node-rdkafka/blob/master/examples/producer.md