コード例 #1
0
        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));
                    }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: adamtha/ServiceBlocks
        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();
        }
コード例 #3
0
ファイル: Server.cs プロジェクト: AlonAmsalem/ServiceBlocks
        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();
        }
コード例 #4
0
ファイル: Server.cs プロジェクト: adamtha/ServiceBlocks
        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();
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: AlonAmsalem/ServiceBlocks
        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();
        }
コード例 #6
0
        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));
            }
        }