public static Rabbit Initialize(Assembly assembly = null) { if (_rabbit == null) _rabbit = new Rabbit(); else throw new Exception("Rabbit already initialized"); if(_rabbit.Log.IsInfoEnabled) _rabbit.Log.Info("Initializing Rabbit's container..."); ContainerBootstrap.Initialize(new NRabbitModule(true, assembly)); if (_rabbit.Log.IsInfoEnabled) _rabbit.Log.Info("Rabbit's container initialized."); return _rabbit; }
public static void Close() { var log = LogManager.GetLogger(typeof (Rabbit).FullName); if (log.IsInfoEnabled) log.Info("Closing Rabbit..."); if (ComponentLocator.Current != null) { var subscribers = ComponentLocator.Current.GetAll<IMessageSubscriber>(); foreach (var messageSubscriber in subscribers) { messageSubscriber.Unsubscribe(); } } Subscriber.StopReconnecting(); ComponentLocator.Dispose(); _rabbit = null; if (log.IsInfoEnabled) log.Info("Rabbit closed"); }