Пример #1
1
        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();
        }
Пример #2
0
        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"));
        }
Пример #3
0
 public CommandQueueListener(IEventStore eventStore, ICommandQueue commandQueue, ICommandDispatcher commandDispatcher)
 {
     _eventStore        = eventStore;
     _commandQueue      = commandQueue;
     _commandDispatcher = commandDispatcher;
     _queueName         = typeof(TAggregate).Name;
 }
Пример #4
0
        public NavigationModule(ITerrain terrain, IPosition startPosition, ICommandQueue <Command> commandQueue)
        {
            _terrain  = terrain;
            _position = startPosition;

            _commandsQueue = commandQueue;
        }
Пример #5
0
        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();
        }
Пример #6
0
 public CommandHistoryFileLoader(PersistenceLayerSettings settings, ICommandQueue commandQueue,
                                 ILogger logger)
 {
     _settings     = settings;
     _commandQueue = commandQueue;
     _logger       = logger;
 }
Пример #7
0
 public PaymentManager(
     ICommandQueue <SubmitPaymentCommand> submitPaymentCommandQueue,
     IPaymentRepository paymentRepository)
 {
     _submitPaymentCommandQueue = submitPaymentCommandQueue;
     _paymentRepository         = paymentRepository;
 }
Пример #8
0
        public UmbrellaProcessManager(ICommandQueue commander, IEventQueue publisher, IQuerySearch querySearch)
        {
            _querySearch = querySearch;

            publisher.Subscribe <TransferStarted>(Handle);
            commander.Override <RenamePerson>(Handle, Tenants.Umbrella.Identifier);
        }
Пример #9
0
 public ShoppingListCommunicationService(IApiClient apiClient, ICommandQueue commandQueue,
                                         IShoppingListNotificationService notificationService)
 {
     this.apiClient           = apiClient;
     this.commandQueue        = commandQueue;
     this.notificationService = notificationService;
 }
Пример #10
0
		public ConsoleHandler(ICommandQueue commandQueue)
		{
			_commandQueue = commandQueue;
			Thread thread = new Thread(ReadConsoleInput);
			thread.IsBackground = true;
			thread.Start();
		}
Пример #11
0
 public CreatePaymentProcessor(
     ICommandQueue <SubmitPaymentCommand> commandQueue,
     ICreatePaymentManager createPaymentManager)
 {
     _commandQueue         = commandQueue;
     _createPaymentManager = createPaymentManager;
 }
Пример #12
0
 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);
 }
Пример #13
0
 public MapSectionUnitMover(IGridUnitManager gridUnitManager,
                            IMapSectionData mapSectionData,
                            ICommandQueue commandQueue)
 {
     _gridUnitManager = gridUnitManager;
     _mapSectionData  = mapSectionData;
     _commandQueue    = commandQueue;
 }
Пример #14
0
        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);
        }
Пример #16
0
        public void SetUp()
        {
            _mockTerrain      = MockRepository.GenerateMock <ITerrain>();
            _mockPosition     = MockRepository.GenerateMock <IPosition>();
            _mockCommandQueue = MockRepository.GenerateMock <ICommandQueue <Command> >();

            _sut = new NavigationModule(_mockTerrain, _mockPosition, _mockCommandQueue);
        }
Пример #17
0
        public UserCommandSubscriber(ICommandQueue commander, IEventQueue publisher, IEventRepository repository)
        {
            _repository = repository;
            _publisher  = publisher;

            commander.Subscribe <StartUserRegistration>(Handle);
            commander.Subscribe <CompleteUserRegistration>(Handle);
        }
Пример #18
0
 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;
 }
Пример #20
0
        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);
        }
Пример #22
0
        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);
        }
Пример #24
0
        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"));
        }
Пример #25
0
        public UserRegistrationProcessManager(ICommandQueue commander, IEventQueue publisher, IQuerySearch querySearch)
        {
            _commander   = commander;
            _querySearch = querySearch;

            publisher.Subscribe <UserRegistrationStarted>(Handle);
            publisher.Subscribe <UserRegistrationSucceeded>(Handle);
            publisher.Subscribe <UserRegistrationFailed>(Handle);
        }
Пример #26
0
 public CommandFactory(ICommandQueue incomingQueue,
                       ICommandQueue outgoingQuue,
                       OrderMediator orderMediator,
                       SessionMediator sessionMediator)
 {
     IncomingQueue = incomingQueue;
     OutgoingQueue = outgoingQuue;
     _orderMediator = orderMediator;
     _sessionMediator = sessionMediator;
 }
Пример #27
0
        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();
        }
Пример #28
0
 public CommandFactory(ICommandQueue incomingQueue,
                       ICommandQueue outgoingQuue,
                       OrderMediator orderMediator,
                       SessionMediator sessionMediator)
 {
     IncomingQueue    = incomingQueue;
     OutgoingQueue    = outgoingQuue;
     _orderMediator   = orderMediator;
     _sessionMediator = sessionMediator;
 }
Пример #29
0
 public CommandDispatcher(ICommandStore commandStore,
                          ICommandQueue commandQueue,
                          IJobFactory jobFactory,
                          IJobFollower jobFollower)
 {
     _commandStore = commandStore;
     _commandQueue = commandQueue;
     _jobFactory   = jobFactory;
     _jobFollower  = jobFollower;
 }
Пример #30
0
        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()));
            }
        }
Пример #31
0
 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);
 }
Пример #32
0
        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);
        }
Пример #33
0
        public WebScrapper(ICommandBus commandBus, ICommandQueue commandQueue, ILogger logger)
        {
            _commandBus   = commandBus;
            _commandQueue = commandQueue;

            _logger = logger;
            logger.SetSource(typeof(WebScrapper).Name);

            _sleepDuration = 10 * 60000;    // configuration
        }
Пример #34
0
        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;
        }
Пример #35
0
        public Infrastructure()
        {
            var container = new WindsorContainer();

            container.Install(
                new OnewayRhinoServiceBusInstaller()
                );

            container.Register(Component.For<ICommandQueue>().ImplementedBy<RhinoEsbOneWayCommandQueue>());
            //
            // Enqueue command
            //
            commandSender = container.Resolve<ICommandQueue>();
        }
Пример #36
0
        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;
        }
Пример #37
0
        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);
            }
        }
Пример #38
0
        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);
            }
        }
Пример #39
0
        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();
                }
            }
        }
Пример #41
0
		public LinkSpamFilter(ICommandQueue commandQueue, IDataSource dataSource) : base(commandQueue, dataSource)
		{
		}
Пример #42
0
		public PollHandler(ICommandQueue commandQueue, IDataSource dataSource, ILog logger) : base(commandQueue, dataSource)
		{
			_logger = logger;
		}
Пример #43
0
		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;
 }
Пример #47
0
		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;
 }