public CommandProcessor(ICommandProcessingStrategy processingStrategy, ICommandQueue commandQueue) { _processingStrategy = processingStrategy; _commandQueue = commandQueue; _cancellationTokenSource = new CancellationTokenSource(); var token = _cancellationTokenSource.Token; var task = new Task( () => { while (!token.IsCancellationRequested) { var cmd = _commandQueue.Dequeue(); while (cmd != null) { _processingStrategy.ProcessCommand(cmd.Execute); cmd = commandQueue.Dequeue(); } Thread.Sleep(100); } }, token, TaskCreationOptions.LongRunning); task.Start(); }
public static void Run(ICommandQueue commander) { var alice = Guid.NewGuid(); commander.Send(new RegisterPerson(alice, "Alice", "O'Wonderland")); commander.Send(new RenamePerson(alice, "Alice", "Cooper")); }
public CommandQueueListener(IEventStore eventStore, ICommandQueue commandQueue, ICommandDispatcher commandDispatcher) { _eventStore = eventStore; _commandQueue = commandQueue; _commandDispatcher = commandDispatcher; _queueName = typeof(TAggregate).Name; }
public NavigationModule(ITerrain terrain, IPosition startPosition, ICommandQueue <Command> commandQueue) { _terrain = terrain; _position = startPosition; _commandsQueue = commandQueue; }
public CommandHistoryFileLoader(PersistenceLayerSettings settings, ICommandQueue commandQueue, ILogger logger) { _settings = settings; _commandQueue = commandQueue; _logger = logger; }
public PaymentManager( ICommandQueue <SubmitPaymentCommand> submitPaymentCommandQueue, IPaymentRepository paymentRepository) { _submitPaymentCommandQueue = submitPaymentCommandQueue; _paymentRepository = paymentRepository; }
public UmbrellaProcessManager(ICommandQueue commander, IEventQueue publisher, IQuerySearch querySearch) { _querySearch = querySearch; publisher.Subscribe <TransferStarted>(Handle); commander.Override <RenamePerson>(Handle, Tenants.Umbrella.Identifier); }
public ShoppingListCommunicationService(IApiClient apiClient, ICommandQueue commandQueue, IShoppingListNotificationService notificationService) { this.apiClient = apiClient; this.commandQueue = commandQueue; this.notificationService = notificationService; }
public ConsoleHandler(ICommandQueue commandQueue) { _commandQueue = commandQueue; Thread thread = new Thread(ReadConsoleInput); thread.IsBackground = true; thread.Start(); }
public CreatePaymentProcessor( ICommandQueue <SubmitPaymentCommand> commandQueue, ICreatePaymentManager createPaymentManager) { _commandQueue = commandQueue; _createPaymentManager = createPaymentManager; }
public static void Enqueue <TCommand, TData>(this ICommandQueue commandQueue, CommandSource source) where TCommand : class, ICommand where TData : ISerializable, new() { commandQueue.Enqueue(typeof(TCommand), typeof(TData), new TData(), source); }
public MapSectionUnitMover(IGridUnitManager gridUnitManager, IMapSectionData mapSectionData, ICommandQueue commandQueue) { _gridUnitManager = gridUnitManager; _mapSectionData = mapSectionData; _commandQueue = commandQueue; }
public CommandBus(IHandlerFactory handlerFactory, ICommandQueue commandQueue, ILogger logger) { _handlerFactory = handlerFactory; _commandQueue = commandQueue; _logger = logger; _logger.SetSource(typeof(CommandBus).Name); }
public void Construct(ICommandQueue commandQueue, IInputLock inputLock) { _commandQueue = commandQueue; _inputLock = inputLock; Preconditions.CheckNotNull(_stopPaintingButton, _drawingTools, _colorPicker, _brushSizeSlider); }
public void SetUp() { _mockTerrain = MockRepository.GenerateMock <ITerrain>(); _mockPosition = MockRepository.GenerateMock <IPosition>(); _mockCommandQueue = MockRepository.GenerateMock <ICommandQueue <Command> >(); _sut = new NavigationModule(_mockTerrain, _mockPosition, _mockCommandQueue); }
public UserCommandSubscriber(ICommandQueue commander, IEventQueue publisher, IEventRepository repository) { _repository = repository; _publisher = publisher; commander.Subscribe <StartUserRegistration>(Handle); commander.Subscribe <CompleteUserRegistration>(Handle); }
public RegionController(ICommandQueue commandQueue, INationRepository nationRepository, IRegionRepository regionRepository, ISessionRepository sessionRepository, IUserRepository userRepository) { CommandQueue = commandQueue; NationRepository = nationRepository; RegionRepository = regionRepository; SessionRepository = sessionRepository; UserRepository = userRepository; }
public UnitMoveAnimator(IGridUnitManager gridUnitManager, IGridInputManager gridInputManager, ICommandQueue commandQueue, ILogger logger) { _gridUnitManager = gridUnitManager; _gridInputManager = gridInputManager; _commandQueue = commandQueue; _logger = logger; }
public TransferProcessManager(ICommandQueue commander, IEventQueue publisher, IEventRepository repository) { _commander = commander; _repository = repository; publisher.Subscribe <TransferStarted>(Handle); publisher.Subscribe <MoneyDeposited>(Handle); publisher.Subscribe <MoneyWithdrawn>(Handle); }
public ReplayPlaybackManager(ICommandQueue commandQueue, IClock clock, ILogger logger) { _commandQueue = commandQueue; _clock = clock; _logger = logger; // We do this here and not as part of IInitializable to avoid race condition issues. _commandQueue.AddListener(this); }
public TransferCommandSubscriber(ICommandQueue commander, IEventQueue publisher, IEventRepository repository) { _repository = repository; _publisher = publisher; commander.Subscribe <StartTransfer>(Handle); commander.Subscribe <UpdateTransfer>(Handle); commander.Subscribe <CompleteTransfer>(Handle); }
public GetLinksCommandHandler(IDataRepository <Link> linkRepository, ICommandQueue commandRepository, IFactory <ILinkGatherer> factory, ILogger logger) { _dataRepository = linkRepository; _commandQueue = commandRepository; _factory = factory; _logger = logger; _logger.SetSource(typeof(GetLinksCommandHandler).Name); }
public static void Run(ICommandQueue commander) { ProgramSettings.CurrentTenant = Tenants.Umbrella; var alice = Guid.NewGuid(); commander.Send(new RegisterPerson(alice, "Alice", "Abernathy")); commander.Send(new RenamePerson(alice, "Alice", "Parks")); }
public UserRegistrationProcessManager(ICommandQueue commander, IEventQueue publisher, IQuerySearch querySearch) { _commander = commander; _querySearch = querySearch; publisher.Subscribe <UserRegistrationStarted>(Handle); publisher.Subscribe <UserRegistrationSucceeded>(Handle); publisher.Subscribe <UserRegistrationFailed>(Handle); }
public CommandFactory(ICommandQueue incomingQueue, ICommandQueue outgoingQuue, OrderMediator orderMediator, SessionMediator sessionMediator) { IncomingQueue = incomingQueue; OutgoingQueue = outgoingQuue; _orderMediator = orderMediator; _sessionMediator = sessionMediator; }
public static void Run(ICommandQueue commander) { var alice = Guid.NewGuid(); var tomorrow = DateTimeOffset.UtcNow.AddDays(1); commander.Schedule(new RegisterPerson(alice, "Alice", "O'Wonderland"), tomorrow); // After the above timer elapses, any call to Ping() executes the scheduled command. // commander.Ping(); }
public CommandDispatcher(ICommandStore commandStore, ICommandQueue commandQueue, IJobFactory jobFactory, IJobFollower jobFollower) { _commandStore = commandStore; _commandQueue = commandQueue; _jobFactory = jobFactory; _jobFollower = jobFollower; }
public static void Run(ICommandQueue commander) { var henry = Guid.NewGuid(); commander.Send(new RegisterPerson(henry, "King", "Henry I")); for (int i = 1; i <= 20; i++) { commander.Send(new RenamePerson(henry, "King", "Henry " + (i + 1).ToRoman())); } }
public GatherDataCommandHandler(IDataRepository <Link> linkRepository, IDataRepository <HtmlData> htmlDataRepository, ICommandQueue commandQueue, IDataGatherer dataGatherer, ILogger logger) { _linkRepository = linkRepository; _htmlDataRepository = htmlDataRepository; _commandQueue = commandQueue; _dataGatherer = dataGatherer; _logger = logger; _logger.SetSource(typeof(GatherDataCommand).Name); }
public AccountCommandSubscriber(ICommandQueue commander, IEventQueue publisher, IEventRepository repository) { _repository = repository; _publisher = publisher; commander.Subscribe <OpenAccount>(Handle); commander.Subscribe <DepositMoney>(Handle); commander.Subscribe <WithdrawMoney>(Handle); commander.Subscribe <CloseAccount>(Handle); }
public WebScrapper(ICommandBus commandBus, ICommandQueue commandQueue, ILogger logger) { _commandBus = commandBus; _commandQueue = commandQueue; _logger = logger; logger.SetSource(typeof(WebScrapper).Name); _sleepDuration = 10 * 60000; // configuration }
public Sender(NetworkStream stream, ICommandQueue commandQueue, CancellationToken cancelToken) { if (stream == null) throw new ArgumentNullException("stream"); if (commandQueue == null) throw new ArgumentNullException("commandQueue"); Stream = stream; Commands = commandQueue; CancelToken = cancelToken; }
public Infrastructure() { var container = new WindsorContainer(); container.Install( new OnewayRhinoServiceBusInstaller() ); container.Register(Component.For<ICommandQueue>().ImplementedBy<RhinoEsbOneWayCommandQueue>()); // // Enqueue command // commandSender = container.Resolve<ICommandQueue>(); }
public BattleNetClient(IBattleNetSettings settings) : base(settings.Gateway.ServerHost, settings.Gateway.ServerPort) { ValidateSettings(settings); m_settings = settings; m_priorityProvider = new CombinedPacketPriorityProvider(); InitializeListenState(); InitializeParseDictionaries(); m_queue = new DefaultCommandQueue(); m_messageReadyCallback = SendCallbackImpl; m_queue.MessageReady += m_messageReadyCallback; }
public void RetryCommand(CommandInfo commandInfo, ErrorInfo errorInfo, ActionInfo retrySuccessCallbackAction) { if (_retryCommandQueue == null) { _retryCommandQueue = Configuration.Instance.GetRetryCommandQueue(); } var command = commandInfo.Command; Action<CommandInfo, ActionInfo> actionAfterCommandRetried = (currentCommandInfo, callbackActionInfo) => { currentCommandInfo.IncreaseRetriedCount(); _logger.InfoFormat("Sent {0} to command retry queue for {1} time.", currentCommandInfo.Command.GetType().Name, currentCommandInfo.RetriedCount); callbackActionInfo.Action(callbackActionInfo.Data); }; if (commandInfo.RetriedCount < command.RetryCount) { if (_retryService.TryAction("TryEnqueueCommand", () => TryEnqueueCommand(command), 2)) { actionAfterCommandRetried(commandInfo, retrySuccessCallbackAction); } else { _retryService.RetryInQueue( new ActionInfo( "TryEnqueueCommand", (obj) => TryEnqueueCommand(obj as ICommand), command, new ActionInfo( "TryEnqueueCommandFinishedAction", (obj) => { var data = obj as dynamic; var currentCommandInfo = data.CommandInfo as CommandInfo; var callbackActionInfo = data.Callback as ActionInfo; actionAfterCommandRetried(currentCommandInfo, callbackActionInfo); return true; }, new { CommandInfo = commandInfo, Callback = retrySuccessCallbackAction }, null))); } } else { _commandAsyncResultManager.TryComplete(commandInfo.Command.Id, errorInfo.ErrorMessage, errorInfo.Exception); } }
public void RetryCommand(CommandInfo commandInfo, Exception exception) { if (_retryCommandQueue == null) { _retryCommandQueue = Configuration.Instance.GetRetryCommandQueue(); } if (commandInfo.RetriedCount < commandInfo.Command.RetryCount) { _retryCommandQueue.Enqueue(commandInfo.Command); commandInfo.IncreaseRetriedCount(); _logger.InfoFormat("Sent {0} to command retry queue for {1} time.", commandInfo.Command.GetType().Name, commandInfo.RetriedCount); } else { _commandAsyncResultManager.TryComplete(commandInfo.Command.Id, exception.Message, exception); } }
public void Start(TwitchIrcClient client, ICommandQueue queue) { while (!stopRunning) { var command = queue.DequeueCommand(); if (string.IsNullOrWhiteSpace(command)) { _resetEvent.WaitOne(); } if (command != "exit") { client.SendRawMessage(command); } else if (command == "exit") { stopRunning = true; } } }
/// <summary>Retry the given command. /// </summary> /// <param name="commandInfo"></param> /// <param name="eventStream"></param> /// <param name="errorInfo"></param> /// <param name="retrySuccessCallbackAction"></param> public void RetryCommand(CommandInfo commandInfo, EventStream eventStream, ErrorInfo errorInfo, Action retrySuccessCallbackAction) { if (_retryCommandQueue == null) { _retryCommandQueue = Configuration.Instance.GetRetryCommandQueue(); } var command = commandInfo.Command; if (commandInfo.RetriedCount < command.RetryCount) { _retryService.TryAction("TryEnqueueCommand", () => TryEnqueueCommand(commandInfo), 3, retrySuccessCallbackAction); } else { _commandAsyncResultManager.TryComplete(command.Id, eventStream.AggregateRootId, errorInfo); _logger.InfoFormat("{0} retried count reached to its max retry count {1}.", command.GetType().Name, command.RetryCount); if (retrySuccessCallbackAction != null) { retrySuccessCallbackAction(); } } }
public LinkSpamFilter(ICommandQueue commandQueue, IDataSource dataSource) : base(commandQueue, dataSource) { }
public PollHandler(ICommandQueue commandQueue, IDataSource dataSource, ILog logger) : base(commandQueue, dataSource) { _logger = logger; }
protected ModChatParser(ICommandQueue commandQueue, IDataSource dataSource) { _dataSource = dataSource; _commandQueue = commandQueue; }
public ServiceWork(ITimer timer, ICommandQueue queue) { _timer = timer; _queue = queue; }
public SyncWithEcommerceEventHandler(ILogger logger, ICommandQueue commandQueue) { _logger = logger; _commandQueue = commandQueue; }
public ForwardConfirmedBillOfLadingToInventory(ICommandQueue commandQueue, IRepository repository) { _commandQueue = commandQueue; _repository = repository; }
public UptimeHandler(ICommandQueue commandQueue, ITwitchApi twitchApi) { _twitchApi = twitchApi; _commandQueue = commandQueue; _lastRequests = new ConcurrentDictionary<string, DateTime>(); }
public StockIncomingItemCommandHandler(ILogger logger, IRepository repository, ICommandQueue commandQueue) { _logger = logger; _repository = repository; _commandQueue = commandQueue; }