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(); } }
protected override void Run(CancellationToken cancellationToken) { var busFactory = new BusFactory().WithScan() .WithConfiguration("tcp://localhost:129", "Demo") .WithPeerId("Receiver.*"); using (busFactory.CreateAndStartBus()) { cancellationToken.WaitHandle.WaitOne(); } }
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); } } }