예제 #1
0
        /// <summary>
        /// Asynchronously processes an event queue by dispatching the events
        /// </summary>
        /// <param name="preTransaction">True, if pre-transaction handlers required</param>
        /// <param name="queue">The event queue to process</param>
        private async Task ProcessEventQueue(IEventQueue queue, bool preTransaction = false)
        {
            var queueTasks = new List <Task>();

            while (false == queue.IsEmpty())
            {
                var nextItem     = queue.GetNext();
                var dispatchTask = _eventDispatcher.DispatchAsync(nextItem.Event, preTransaction);

                queueTasks.Add(dispatchTask);

                // We don't want to log pre-transaction events
                if (false == preTransaction)
                {
                    var logTask = _eventLogger.LogEventAsync
                                  (
                        nextItem.AggregateKey,
                        nextItem.AggregateType,
                        nextItem.Event
                                  );

                    queueTasks.Add(logTask);
                }
            }

            await Task.WhenAll(queueTasks).ConfigureAwait(false);
        }
예제 #2
0
        /// <summary>
        /// Processes an event queue by dispatching the events
        /// </summary>
        /// <param name="preTransaction">True, if pre-transaction handlers required</param>
        /// <param name="queue">The event queue to process</param>
        private void ProcessEventQueue
        (
            IEventQueue queue,
            bool preTransaction = false
        )
        {
            while (false == queue.IsEmpty())
            {
                var nextItem = queue.GetNext();

                _eventDispatcher.Dispatch
                (
                    nextItem.Event,
                    preTransaction
                );

                // We don't want to log pre-transaction events
                if (false == preTransaction)
                {
                    _eventLogger.LogEvent
                    (
                        nextItem.AggregateKey,
                        nextItem.AggregateType,
                        nextItem.Event
                    );
                }
            }
        }
예제 #3
0
        public void Add(IEventQueue queue)
        {
            if (queue.IsEmpty())
            {
                throw new Exception($"EventTree::Add Can not add queue, the queue is empty : {queue.Name}");
            }

            var item = new EventTreeItem(queue);

            if (this.eventTreeItem_0 == null)
            {
                this.eventTreeItem_0 = item;
                return;
            }
            this.method_0(item);
        }
예제 #4
0
        public void Add(IEventQueue queue)
        {
            if (queue.IsEmpty())
                throw new Exception($"EventTree::Add Can not add queue, the queue is empty : {queue.Name}");

            var item = new EventTreeItem(queue);
            if (this.eventTreeItem_0 == null)
            {
                this.eventTreeItem_0 = item;
                return;
            }
            this.method_0(item);
        }