Esempio n. 1
0
        public static void Main()
        {
            Console.CancelKeyPress += (sender, eventArgs) =>
            {
                eventArgs.Cancel = true;
                _cancelKeySignal.Set();
            };

            XmlConfigurator.ConfigureAndWatch(new FileInfo(PathUtil.InBaseDirectory("log4net.config")));
            _log.Info("Starting in memory directory");

            var busFactory = new BusFactory();
            InjectDirectoryServiceSpecificConfiguration(busFactory);

            busFactory
                .WithConfiguration(new AppSettingsBusConfiguration(), ConfigurationManager.AppSettings["Environment"])
                .WithScan()
                .WithEndpoint(ConfigurationManager.AppSettings["Endpoint"])
                .WithPeerId(ConfigurationManager.AppSettings["PeerId"]);

            using (busFactory.CreateAndStartBus())
            {
                _log.Info("In memory directory started");

                _log.Info("Starting dead peer detector");
                var deadPeerDetector = busFactory.Container.GetInstance<IDeadPeerDetector>();
                deadPeerDetector.Start();

                _cancelKeySignal.WaitOne();

                _log.Info("Stopping dead peer detector");
                deadPeerDetector.Stop();
            }
        }
Esempio n. 2
0
        protected override void Run(CancellationToken cancellationToken)
        {
            var busFactory = new BusFactory().WithScan()
                                             .WithConfiguration("tcp://localhost:129", "Demo")
                                             .WithPeerId("Receiver.*");

            using (busFactory.CreateAndStartBus())
            {
                cancellationToken.WaitHandle.WaitOne();
            }
        }
Esempio n. 3
0
        protected override void Run(CancellationToken cancellationToken)
        {
            var busFactory = new BusFactory().WithConfiguration("tcp://localhost:129", "Demo")
                                             .WithPeerId("Publisher.*");

            using (var bus = busFactory.CreateAndStartBus())
            {
                while (!cancellationToken.IsCancellationRequested)
                {
                    bus.Publish(new SomethingHappened());

                    Thread.Sleep(500);
                }
            }
        }