I am trying to use Headers with the Confluent Kafka C# API but the Message<> template does not have a Headers parameter. How do you pass in headers to the ProduceAsync method?
var header = new Headers();
    
    
header.Add(“key”, Encoding.UTF8.GetBytes(“value”)) ;
    
var config = new ProducerConfig
{
    BootstrapServers = "localhost:9092",
};
var _producer = new ProducerBuilder<Null, string>(config).Build();
var stringMessage = "Your message";
await _producer.ProduceAsync(topic, new Message<Null, string> { Key = null, Value = stringMessage, Headers = header });
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With