public void TestPush() { string address = string.Format("tcp://localhost:22245"); using (var acceptor = new NetMqPushAcceptor(address)) using (var pusher = new NetMqPusher(address)) using (var countDown = new CountdownEvent(2)) { acceptor.Start(); acceptor.Subscribe("test", m => { if (!countDown.IsSet) { countDown.Signal(); } }); pusher.Start(); Task.Run(() => { while (!countDown.IsSet) { pusher.Publish("test", new byte[] { 1, 2, 3 }); Thread.Sleep(100); } }); Assert.IsTrue(countDown.Wait(5000)); } }
private static void Main(string[] args) { string address = ConfigurationManager.AppSettings["ServerAddress"]; string snapshotaddress = ConfigurationManager.AppSettings["SnapshotServerAddress"]; string gatewayaddress = ConfigurationManager.AppSettings["GatewayServerAddress"]; var snapshotServer = new NetMqSnapshotServer(snapshotaddress, CreateSnapshot); snapshotServer.Start(); var publisher = new NetMqPublisher(address); publisher.Start(); var gateway = new NetMqPushAcceptor(gatewayaddress); gateway.Subscribe("q", message => { Quote q = BinarySerializer <Quote> .DeSerializeFromByteArray(message); QuotesCache[q.InstrumentId] = q; publisher.Publish("q", message); }); gateway.Start(); Console.ReadKey(); }
public void Start() { _processor = new FeedProcessor(OnValidQuote, OnInvalidQuote); _processor.Start(); _snapshotServer = new NetMqSnapshotServer(_snapshotAddress, CreateSnapshot); _snapshotServer.Start(); _publisher = new NetMqPublisher(_publisherAddress); _publisher.Start(); _gateway = new NetMqPushAcceptor(_gatewayAddress); _gateway.Subscribe(Constants.QuotesTopicName, message => { //TODO: try use protobuff var rawQuotes = BinarySerializer<IEnumerable<Quote>>.DeSerializeFromByteArray(message); _processor.ProcessQuotes(rawQuotes); }); _gateway.Start(); }
public void Start() { //Debug.WriteLine(TimerResolution.SetResolution(500)); _processor = new FeedProcessor(OnValidQuote, OnInvalidQuote); _processor.Start(); _snapshotServer = new NetMqSnapshotServer(_snapshotAddress, CreateSnapshot); _snapshotServer.Start(); _publisher = new NetMqPublisher(_publisherAddress); _publisher.Start(); _gateway = new NetMqPushAcceptor(_gatewayAddress); _gateway.Subscribe(Constants.QuotesTopicName, message => { //TODO: try use protobuff var rawQuotes = BinarySerializer <IEnumerable <Quote> > .DeSerializeFromByteArray(message); _processor.ProcessQuotes(rawQuotes); }); _gateway.Start(); }
private static void Main(string[] args) { string address = ConfigurationManager.AppSettings["ServerAddress"]; string snapshotaddress = ConfigurationManager.AppSettings["SnapshotServerAddress"]; string gatewayaddress = ConfigurationManager.AppSettings["GatewayServerAddress"]; var snapshotServer = new NetMqSnapshotServer(snapshotaddress, CreateSnapshot); snapshotServer.Start(); var publisher = new NetMqPublisher(address); publisher.Start(); var gateway = new NetMqPushAcceptor(gatewayaddress); gateway.Subscribe("q", message => { Quote q = BinarySerializer<Quote>.DeSerializeFromByteArray(message); QuotesCache[q.InstrumentId] = q; publisher.Publish("q", message); }); gateway.Start(); Console.ReadKey(); }
public void TestPush() { string address = string.Format("tcp://localhost:22245"); using (var acceptor = new NetMqPushAcceptor(address)) using (var pusher = new NetMqPusher(address)) using (var countDown = new CountdownEvent(2)) { acceptor.Start(); acceptor.Subscribe("test", m => { if (!countDown.IsSet) countDown.Signal(); }); pusher.Start(); Task.Run(() => { while (!countDown.IsSet) { pusher.Publish("test", new byte[] {1, 2, 3}); Thread.Sleep(100); } }); Assert.IsTrue(countDown.Wait(5000)); } }