Ejemplo n.º 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();
            }
        }
Ejemplo n.º 2
0
        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)
                {
                }
            }
        }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 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();
                }
        }
Ejemplo n.º 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");
                }
        }