public void Messages_are_queued() { var block = new AutoResetEvent(false); var serializer = new ProtocolBuffersSerializer(); var socket = new ZmqConsumer<StringEvent>("tcp://127.0.0.1:5000", serializer); var consumer = new DelegatingConsumer<StringEvent>(Console.WriteLine, socket); // logs to console before forwarding var producer = new ObservingProducer<StringEvent>(); producer.Attach(consumer); producer.Produces(GetPayload(), onCompleted: () => block.Set()); producer.Start(); block.WaitOne(); socket.Dispose(); }
public void Messages_are_queued() { var block = new AutoResetEvent(false); var serializer = new ProtocolBuffersSerializer(); var socket = new ZmqConsumer <StringEvent>("tcp://127.0.0.1:5000", serializer); var consumer = new DelegatingConsumer <StringEvent>(Console.WriteLine, socket); // logs to console before forwarding var producer = new ObservingProducer <StringEvent>(); producer.Attach(consumer); producer.Produces(GetPayload(), onCompleted: () => block.Set()); producer.Start(); block.WaitOne(); socket.Dispose(); }
public void Messages_are_dequeued() { var block = new AutoResetEvent(false); const int sent = 10; var received = 0; // Anything handled is sent to zmq var consumer = new ZmqConsumer <StringEvent>("tcp://127.0.0.1:5000"); // Anything taken from zmq goes to the console and is counted var producer = new ZmqProducer <StringEvent>("tcp://127.0.0.1:5000").Consumes(@event => { Console.WriteLine(@event.Text); received++; if (received >= sent) { block.Set(); } }); producer.Start(); consumer.Handle(new StringEvent("Test1")); consumer.Handle(new StringEvent("Test2")); consumer.Handle(new StringEvent("Test3")); consumer.Handle(new StringEvent("Test4")); consumer.Handle(new StringEvent("Test5")); consumer.Handle(new StringEvent("Test6")); consumer.Handle(new StringEvent("Test7")); consumer.Handle(new StringEvent("Test8")); consumer.Handle(new StringEvent("Test9")); consumer.Handle(new StringEvent("Test10")); block.WaitOne(); producer.Dispose(); consumer.Dispose(); }
public void Messages_are_dequeued() { var block = new AutoResetEvent(false); const int sent = 10; var received = 0; // Anything handled is sent to zmq var consumer = new ZmqConsumer<StringEvent>("tcp://127.0.0.1:5000"); // Anything taken from zmq goes to the console and is counted var producer = new ZmqProducer<StringEvent>("tcp://127.0.0.1:5000").Consumes(@event => { Console.WriteLine(@event.Text); received++; if (received >= sent) { block.Set(); } }); producer.Start(); consumer.Handle(new StringEvent("Test1")); consumer.Handle(new StringEvent("Test2")); consumer.Handle(new StringEvent("Test3")); consumer.Handle(new StringEvent("Test4")); consumer.Handle(new StringEvent("Test5")); consumer.Handle(new StringEvent("Test6")); consumer.Handle(new StringEvent("Test7")); consumer.Handle(new StringEvent("Test8")); consumer.Handle(new StringEvent("Test9")); consumer.Handle(new StringEvent("Test10")); block.WaitOne(); producer.Dispose(); consumer.Dispose(); }