示例#1
0
        static void Main(string[] args)
        {
            var subscriberService = new SubscriberService();

            using (IConnection connection = new ConnectionFactory().CreateConnection()){
                subscriberService.Run(connection);
                Console.WriteLine("Events listening started. Press any key to exit");
                Console.ReadKey();
            }
        }
        public static void Main(string[] args)
        {
            var  subscriberService = new SubscriberService();
            bool isCancel          = false;

            string natsHost = Environment.GetEnvironmentVariable("NATS_HOST");
            string natsPort = Environment.GetEnvironmentVariable("NATS_PORT");

            using (IConnection connection = new ConnectionFactory().CreateConnection("nats://" + natsHost + ":" + natsPort))
            {
                subscriberService.Run(connection);
                Console.WriteLine("Events listening started");
                Console.CancelKeyPress += (sender, args) => { isCancel = true; };
                while (!isCancel)
                {
                }
            }
        }
示例#3
0
        static void Main(string[] args)
        {
            string currentDirectoryPath = Directory.GetCurrentDirectory();
            string jsonPath             = Directory.GetParent(currentDirectoryPath) + "/config/config.json";
            var    config = new ConfigurationBuilder()
                            .SetBasePath(Directory.GetCurrentDirectory())
                            .AddJsonFile(jsonPath, optional: false)
                            .Build();

            var subscriberService = new SubscriberService();

            using (IConnection connection = new ConnectionFactory().CreateConnection($"http://localhost:{config.GetValue<int>("NatsPort")}"))
            {
                subscriberService.Run(connection);
                Console.WriteLine("Monitoring starting:");
                Console.ReadKey();
            }
        }
示例#4
0
        static void Main(string[] args)
        {
            var subscriberService = new SubscriberService();

            using (IConnection connection = new ConnectionFactory().CreateConnection("nats://" + Environment.GetEnvironmentVariable("NATS_HOST")))
                using (ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(Environment.GetEnvironmentVariable("REDIS_HOST")))
                {
                    subscriberService.Run(connection, redis);
                    Console.WriteLine("Events listening started.");

                    Task.Factory.StartNew(() =>
                    {
                        while (true)
                        {
                            Console.WriteLine(DateTime.Now.ToString());
                            Thread.Sleep(1000);
                        }
                    });
                    Console.CancelKeyPress += new ConsoleCancelEventHandler(OnExit);
                    _closing.WaitOne();
                }
        }
示例#5
0
        static void Main(string[] args)
        {
            var subscriber = new SubscriberService();

            using (IConnection nats = new ConnectionFactory().CreateConnection("nats://" + Environment.GetEnvironmentVariable("NATS_HOST")))
                using (ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(Environment.GetEnvironmentVariable("REDIS_HOST")))
                {
                    subscriber.Run(nats, redis);

                    Console.WriteLine("JobLogger service is started");

                    Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e)
                    {
                        e.Cancel        = true;
                        Program.running = false;
                    };

                    while (running)
                    {
                    }

                    Console.WriteLine("JobLogger service is shut down");
                }
        }