-
Notifications
You must be signed in to change notification settings - Fork 233
/
Copy pathProgram.cs
41 lines (35 loc) · 1.11 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Threading.Tasks;
using KafkaNet.Configuration;
using KafkaNet.Model;
using KafkaNet.Protocol;
namespace TestHarness
{
class Program
{
static void Main(string[] args)
{
var bus = new BusFactory().Create(new KafkaOptions
{
Hosts = new[] {new Uri("http://CSDKAFKA01:9092"), new Uri("http://CSDKAFKA02:9092")}
}, x => { });
Task.Factory.StartNew(() =>
{
foreach (var data in bus.Consume("TestHarness"))
{
Console.WriteLine("Response: P{0},O{1} : {2}", data.Meta.PartitionId, data.Meta.Offset, data.Value);
}
});
Console.WriteLine("Type a message and press enter...");
while (true)
{
var message = Console.ReadLine();
if (message == "quit") break;
bus.SendMessageAsync("TestHarness", new[] {new Message {Value = message}});
}
using (bus)
{
}
}
}
}