/*public static Task Handle(ConsumeContext<YourMessage> ctx) * { * foreach (var hdr in ctx.Headers.GetAll()) * { * Console.WriteLine("{0}: {1}", hdr.Key, hdr.Value); * } * return Console.Out.WriteLineAsync($"received: {ctx.Message.Text}"); * }*/ static void Main(string[] args) { Licznik licznik = new Licznik(); var bus = Bus.Factory.CreateUsingRabbitMq(sbc => { var host = sbc.Host(new Uri("rabbitmq://localhost"), h => { h.Username("guest"); h.Password("guest"); }); sbc.ReceiveEndpoint(host, "asyncqueue", ep => { ep.Consumer(() => new HandlerClass(licznik)); }); }); bus.Start(); Console.WriteLine("odbiorca wystartowaĆ"); Console.ReadKey(); bus.Stop(); }
public HandlerClass(Licznik l) { licz = l; }