This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Confluent.Kafka; | |
namespace KafkaProducer | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var config = new ProducerConfig{ BootstrapServers = "kafka-release.kube-kafka.svc.cluster.local:9092" }; | |
using (var producer = new ProducerBuilder<Null, string>(config).Build()) | |
{ | |
var increment = 0; | |
while (increment < int.MaxValue) | |
{ | |
try | |
{ | |
var produceResult = producer.ProduceAsync("increment-topic", | |
new Message<Null, string> { Value = $"The number is {increment}"}) | |
.GetAwaiter() | |
.GetResult(); | |
Console.WriteLine($"Success = {produceResult.Value} to {produceResult.TopicPartitionOffset}"); | |
} | |
catch (Exception ex) | |
{ | |
Console.WriteLine($"Error {ex.Message}"); | |
} | |
increment++; | |
} | |
} | |
Console.WriteLine("Hello World!"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment