Exemple #1
0
 /// <summary>
 /// Adds the <see cref="CommittedEventStreamWithContext" /> to a queue for future processing
 /// </summary>
 /// <param name="committedEventStreamWithContext">the committed event stream with context to queue</param>
 protected virtual void Enqueue(CommittedEventStreamWithContext committedEventStreamWithContext)
 {
     lock (_lockObj)
     {
         _logger.Debug($"Enqueuing stream {committedEventStreamWithContext.EventStream.Sequence} {committedEventStreamWithContext.EventStream.Id} {committedEventStreamWithContext.EventStream.CorrelationId}");
         _queue.Add(committedEventStreamWithContext);
     }
 }
Exemple #2
0
        /// <summary>
        ///  Processes the <see cref="CommittedEventStreamWithContext" />
        /// </summary>
        /// <param name="committedEventStreamWithContext">The <see cref="CommittedEventStream" /> to process</param>
        protected virtual void ProcessStream(CommittedEventStreamWithContext committedEventStreamWithContext)
        {
            _executionContextManager.CurrentFor(committedEventStreamWithContext.Context);
            var committedEventStream = committedEventStreamWithContext.EventStream;

            _logger.Debug($"Processing  stream {committedEventStream.Sequence} {committedEventStream.Id} {committedEventStream.CorrelationId}");
            committedEventStream.Events.ForEach(e => Process(e.ToCommittedEventEnvelope(committedEventStream.Sequence), committedEventStreamWithContext.Context));
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="committedEventStream"></param>
        public void Process(CommittedEventStream committedEventStream)
        {
            var committedEventStreamWithContext = new CommittedEventStreamWithContext(committedEventStream, _executionContextManager.Current);

            _logger.Debug($"Received  stream {committedEventStream.Sequence} {committedEventStream.Id} {committedEventStream.CorrelationId}");
            if (_canProcessEvents.WaitOne(TimeSpan.FromMilliseconds(1)))
            {
                _logger.Debug($"Processing  stream {committedEventStream.Sequence} {committedEventStream.Id} {committedEventStream.CorrelationId}");
                ProcessStream(committedEventStreamWithContext);
            }
            else
            {
                _logger.Debug($"Queuing  stream {committedEventStream.Sequence} {committedEventStream.Id} {committedEventStream.CorrelationId}");
                Enqueue(committedEventStreamWithContext);
            }
        }