Home > OS >  Kafka .NET Client custom timestamp
Kafka .NET Client custom timestamp

Time:11-05

I have been working with the Kafka .NET Client, everything is working but right now the timestamp is automatically set and what I need is to be able to send my own timestamp.

var kp = new kafkaDatapoint
{
   value = p.Value,
   tags = p.tags
};
await _producer.ProduceAsync(p.Variable, new Message<string, kafkaDatapoint>()
                  {
                      Key = p.Variable,
                      Value = kp
                  });

This is the code I use to send the data. How do I override the timestamp?

I am using this package https://docs.confluent.io/clients-confluent-kafka-dotnet

CodePudding user response:

The Message class also has a Timestamp field

https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.Kafka/MessageMetadata.cs#L30

  • Related