Skip to content

Instantly share code, notes, and snippets.

Last active June 25, 2020 22:38
What would you like to do?
Kafka Utility Methods
public static class KafkaUtils
public static IConsumer<int, string> CreateConsumer(string brokerList, List<string> topics)
var config = new ConsumerConfig
BootstrapServers = brokerList,
GroupId = "sample-consumer"
var consumer = new ConsumerBuilder<int, string>(config).Build();
return consumer;
public static IProducer<int, string> CreateProducer(string brokerList)
var config = new ProducerConfig { BootstrapServers = brokerList };
var producer = new ProducerBuilder<int, string>(config).Build();
return producer;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment