public void TestSnapshots()
 {
     string address = string.Format("tcp://localhost:22246");
     using (var server = new NetMqSnapshotServer(address, topic => Encoding.Unicode.GetBytes(topic)))
     {
         server.Start();
         byte[] snapshot =
             Task.Run(() => new NetMqSnapshotClient(address).GetSnapshot("abc"))
                 .ConfigureAwait(true)
                 .GetAwaiter()
                 .GetResult();
         byte[] bytesExpected = Encoding.Unicode.GetBytes("abc");
         CollectionAssert.AreEqual(bytesExpected, snapshot);
     }
 }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
        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();
        }