Brod.Brokers.Broker.Start C# (CSharp) Метод

Start() публичный Метод

public Start ( ) : void
Результат void
        public void Start()
        {
            using(var store = new Store(_configuration))
            {
                var handlers = new RequestHandlers(_configuration, store);

                var engine = new TaskEngine(
                    new SocketListener(ZMQ.SocketType.REP, _configuration.Port, handlers.MapHandlers),
                    new SocketListener(ZMQ.SocketType.PULL, _configuration.PullPort, handlers.MapHandlers),
                    new Flusher(_configuration, store));

                using (var token = new CancellationTokenSource())
                using (engine)
                {
                    var task1 = engine.Start(token.Token, Timeout.Infinite);

                    if (task1.Wait(Timeout.Infinite))
                        Console.WriteLine("Done without forced cancelation"); // This line shouldn't be reached
                    else
                        Console.WriteLine("\r\nRequesting to cancel...");

                    token.Cancel();
                }
            }
        }

Usage Example

Пример #1
0
        public static void Main(string[] args)
        {
            var section = (BrokerConfigurationSection) ConfigurationManager.GetSection("brodBroker");
            var configuration = BrokerConfiguration.FromConfigurationSection(section);

            Console.WriteLine("Brod Broker, v0.0.0.0.1");
            Console.WriteLine("-----------------------");
            Console.WriteLine("  Storage Directory: {0}", configuration.StorageDirectory);
            Console.WriteLine("  Default number of partitions: {0}", configuration.NumberOfPartitions);

            //var socketServer = new SocketServer(configuration.ConsumerPort, configuration.ProducerPort, 1);
            //socketServer.Startup();

            var server = new Broker(configuration);
            server.Start();
        }