public void StopCore() { _state = MqConsumerHostState.StopRunning; try { _channelCallbackExceptionLogger.Clear(); _channelMessageReceivingController.Clear(); try { _mqStatusService.AllQueueDisconnected(); } catch (ObjectDisposedException) { //Ignore it } var runConsumers = _runConsumers.Values.ToArray(); _runConsumers.Clear(); foreach (var runConsumer in runConsumers) { runConsumer.Dispose(); } } catch (Exception e) { _state = MqConsumerHostState.Undefined; _logger.Error(e).Write(); } _state = MqConsumerHostState.Stopped; }
public void Start() { if (_enabledIndicatorService != null && !_enabledIndicatorService.ShouldBeEnabled()) { _logger .Warning("Enabled indicator service indicate `false`. Consuming is not started.") .Write(); return; } if (_state != MqConsumerHostState.Stopped) { _logger .Warning($"An attempt to start consumer host in unsuitable state was detected") .AndFactIs("state", _state) .Write(); } _state = MqConsumerHostState.StartRunning; try { var initialConsumers = _initialConsumerRegistry.GetConsumers(_serviceProvider); foreach (var logicConsumer in initialConsumers) { StartConsumer(logicConsumer); } foreach (var logicConsumer in _runtimeConsumerRegister.Values) { StartConsumer(logicConsumer); } } catch (Exception e) { _state = MqConsumerHostState.Undefined; _logger.Error(e).Write(); } _state = MqConsumerHostState.Running; _logger.Action("Consuming started").Write(); }