/// <summary> /// Handles the specified command. /// </summary> /// <param name="command">The command.</param> /// <returns>TRequest.</returns> public override ConfigurationCommand Handle(ConfigurationCommand command) { switch (command.Type) { case ConfigurationCommandType.CM_STOPALL: _dispatcher.End(); break; case ConfigurationCommandType.CM_STARTALL: _dispatcher.Receive(); break; case ConfigurationCommandType.CM_STOPCHANNEL: _dispatcher.Shut(command.ConnectionName); break; case ConfigurationCommandType.CM_STARTCHANNEL: _dispatcher.Open(command.ConnectionName); break; default: throw new ArgumentException("{0} is an unknown Configuration Command", Enum.GetName(typeof(ConfigurationCommandType), command.Type)); } return(base.Handle(command)); }
public void When_receiving_an_all_stop_message() { _configurationCommandHandler.Handle(_configurationCommand); //_should_call_end_on_the_dispatcher A.CallTo(() => _dispatcher.End()).MustHaveHappened(); }
/// <summary> /// Handles the specified command. /// </summary> /// <param name="command">The command.</param> /// <returns>TRequest.</returns> public override ConfigurationCommand Handle(ConfigurationCommand command) { _logger.Value.DebugFormat("Handling Configuration Command of Type: {0}", command.Type); switch (command.Type) { case ConfigurationCommandType.CM_STOPALL: _logger.Value.DebugFormat("Configuration Command received and now stopping all consumers. Begin at {0}", DateTime.UtcNow.ToString("o")); _logger.Value.Debug("--------------------------------------------------------------------------"); _logger.Value.Debug("..."); _dispatcher.End().Wait(); _logger.Value.DebugFormat("All consumers stopped in response to configuration command. Stopped at {0}", DateTime.UtcNow.ToString("o")); _logger.Value.Debug("--------------------------------------------------------------------------"); break; case ConfigurationCommandType.CM_STARTALL: _logger.Value.Debug("--------------------------------------------------------------------------"); _logger.Value.DebugFormat("Configuration Command received and now starting all consumers. Begin at {0}", DateTime.UtcNow.ToString("o")); _logger.Value.Debug("--------------------------------------------------------------------------"); _dispatcher.Receive(); break; case ConfigurationCommandType.CM_STOPCHANNEL: _logger.Value.Debug("--------------------------------------------------------------------------"); _logger.Value.DebugFormat("Configuration Command received and now stopping channel {0}", command.ConnectionName); _logger.Value.Debug("--------------------------------------------------------------------------"); _dispatcher.Shut(command.ConnectionName); break; case ConfigurationCommandType.CM_STARTCHANNEL: _logger.Value.Debug("--------------------------------------------------------------------------"); _logger.Value.DebugFormat("Configuration Command received and now starting channel {0}", command.ConnectionName); _logger.Value.Debug("--------------------------------------------------------------------------"); _dispatcher.Open(command.ConnectionName); break; default: throw new ArgumentException("{0} is an unknown Configuration Command", Enum.GetName(typeof(ConfigurationCommandType), command.Type)); } return(base.Handle(command)); }
public Task StopAsync(CancellationToken cancellationToken) { _logger.LogInformation("Stopping hosted service dispatcher"); return(_dispatcher.End()); }
/// <summary> /// Handles the specified command. /// </summary> /// <param name="command">The command.</param> /// <returns>TRequest.</returns> public override ConfigurationCommand Handle(ConfigurationCommand command) { dispatcher.End(); return(base.Handle(command)); }