Ejemplo n.º 1
0
    public async Task SImpleCodeSample()
    {
        var count = 100000;

        await Time.Action(
            label : "sending",
            count : count,
            action : async() =>
        {
            var producer = Configure
                           .Producer(c => c.UseKafka("localhost:9092"))
                           .Serialization(s => s.UseNewtonsoftJson())
                           .Create();

            var messages = Enumerable.Range(0, count)
                           .Select(n => new SomeEvent($"This is event number {n}"));

            await Task.WhenAll(messages.Select(m => producer.Send("someevents", new ToposMessage(m))));
        });
    }