コード例 #1
0
        // Processes two types of events
        // 1) Event hub events
        // 2) Maximum wait events. These are generated when we have not received an event hub
        //    event for a certain time period and this event is used to flush events in the current window.
        protected virtual async Task ProcessEventHandler(ProcessEventArgs eventArgs)
        {
            if (eventArgs.CancellationToken.IsCancellationRequested)
            {
                // The event arguments contain a cancellation token that the EventProcessorClient uses to signal the handler that processing should cease as soon as possible.
                // This is most commonly seen when the EventProcessorClient is stopping or has encountered an unrecoverable problem.
                Logger.LogTrace($"ProcessEventArgs contain a cancellation request {eventArgs.Partition.PartitionId}");
                return;
            }

            IEventMessage evt;

            if (eventArgs.HasEvent)
            {
                evt = EventMessageFactory.CreateEvent(eventArgs);
            }
            else
            {
                evt = new MaximumWaitEvent(eventArgs.Partition.PartitionId, DateTime.UtcNow);
            }

            await EventConsumerService.ConsumeEvent(evt);
        }