3

I am working in C# and have the following:

consumer.Subscribe( new string[] {"topic1", "topic2"});
var cr = consumer.Consume();
console.Write($"key {cr.Message.Key}\r\nvalue {cr.Message.Value}");

How do I get the topic of a specific message when I am listening to more than 1 topic?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245

1 Answers1

2

The Consume function returns a ConsumeResult. This has a Topic attribute

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

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245