コード例 #1
0
        /// <summary>
        /// Starts observing commits and dispatching them..
        /// </summary>
        /// <returns></returns>
        public async Task Start()
        {
            if (_isStarted.EnsureCalledOnce())
            {
                return;
            }

            string checkpointToken = await _checkpointRepository.Get();

            /* string checkpointToken = null;
             * await _retryPolicy.Retry(async () => checkpointToken = await _checkpointRepository.Get(), _disposed.Token); //TODO should have different retry policy? */
            _subscription = _eventStoreClient.Subscribe(checkpointToken, async commit =>
            {
                try
                {
                    await _retryPolicy.Retry(() => _dispatchCommit(commit, _disposed.Token), _disposed.Token);
                    await _retryPolicy.Retry(() => _checkpointRepository.Put(commit.CheckpointToken), _disposed.Token);
                }
                catch (Exception ex)
                {
                    Logger.ErrorException(
                        Messages.ExceptionHasOccuredWhenDispatchingACommit.FormatWith(commit.ToString()),
                        ex);
                    _projectedCommits.OnError(ex);
                    throw;
                }
                _projectedCommits.OnNext(commit);
            });
        }
コード例 #2
0
        /// <summary>
        /// Starts observing commits and dispatching them..
        /// </summary>
        /// <returns></returns>
        public async Task Start()
        {
            if (_isStarted.EnsureCalledOnce())
            {
                return;
            }

            string checkpointToken = await _checkpointRepository.Get();

            _subscription = _eventStoreClient.Subscribe(checkpointToken, async commit =>
            {
                try
                {
                    await _dispatchCommit(commit, _disposed.Token);
                    await _checkpointRepository.Put(commit.CheckpointToken);
                }
                catch (Exception ex)
                {
                    Logger.ErrorException(
                        ExtensionMethods.FormatWith(Messages.ExceptionHasOccuredWhenDispatchingACommit, new[] { commit.ToString() }),
                        ex);
                    _projectedCommits.OnError(ex);
                    throw;
                }
                _projectedCommits.OnNext(commit);
            });
        }
コード例 #3
0
ファイル: ProjectionDispatcher.cs プロジェクト: csuffyy/Cedar
        public async Task Start()
        {
            if (_isStarted.EnsureCalledOnce())
            {
                return;
            }

            string checkpointToken = await _checkpointRepository.Get();

            await OnStart(checkpointToken);
        }
コード例 #4
0
        public bool Start(IDomainRepository domainRepository, IEventStoreConnection connection, IEnumerable <Action <ICommand> > preExecutionPipe = null, IEnumerable <Action <object> > postExecutionPipe = null)
        {
            _connection           = connection;
            _domainEntry          = new DomainEntry(domainRepository, preExecutionPipe, postExecutionPipe);
            _checkpointRepository = new EventStoreCheckpointRepository(connection, CheckpointId);
            _latestPosition       = _checkpointRepository.Get();
            var settings = new CatchUpSubscriptionSettings(10, 100, false, true);

            _connection.SubscribeToAllFrom(_latestPosition, settings, HandleEvent);
            Console.WriteLine("AppServiceStrategy started");
            return(true);
        }