27 lines
732 B
C#
27 lines
732 B
C#
using System;
|
|
using Confluent.Kafka;
|
|
class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
string mess = "";
|
|
|
|
while (mess != "quit") {
|
|
|
|
var config = new ProducerConfig
|
|
{
|
|
BootstrapServers = "localhost:9092"
|
|
};
|
|
using var producer = new ProducerBuilder<Null, string>(config).Build();
|
|
Console.Write("Enter message (type 'quit' to quit): ");
|
|
mess = Console.ReadLine();
|
|
var topic = "test-topic";
|
|
var message = new Message<Null, string> { Value = mess };
|
|
producer.Produce(topic, message, deliveryReport => {
|
|
Console.WriteLine(deliveryReport.Message.Value);
|
|
});
|
|
producer.Flush(new TimeSpan(0,0,30));
|
|
}
|
|
}
|
|
}
|