async Task IEventProcessor.ProcessEventsAsync(PartitionContext context, IEnumerable <EventData> messages) { foreach (EventData eventData in messages) { _Logger.LogInfo(string.Format("Event received from partition: {0} - {1}", context.Lease.PartitionId, eventData.PartitionKey)); try { var httpMessage = HttpMessage.Parse(eventData.GetBodyStream()); await _MessageContentProcessor.ProcessHttpMessage(httpMessage); } catch (Exception ex) { _Logger.LogError(ex.Message); } } //Call checkpoint every 5 minutes, so that worker can resume processing from the 5 minutes back if it restarts. if (this.checkpointStopWatch.Elapsed > TimeSpan.FromMinutes(5)) { _Logger.LogInfo("Checkpointing"); await context.CheckpointAsync(); this.checkpointStopWatch.Restart(); } }
async Task IEventProcessor.ProcessEventsAsync(PartitionContext context, IEnumerable <EventData> messages) { foreach (EventData eventData in messages) { var evt = displayableEvent(context, eventData); _Logger.LogDebug("Event received: " + evt); try { var httpMessage = HttpMessage.Parse(eventData.GetBodyStream()); await _MessageContentProcessor.ProcessHttpMessage(httpMessage); } catch (Exception ex) { // Policy.xml errors may result in this exception. _Logger.LogError("Error: " + evt + " - " + ex.Message); } } //Call checkpoint every CHECKPOINT_MINIMUM_INTERVAL_MINUTES minutes, // so that worker can resume processing from that time back if it restarts. if (this.checkpointStopWatch.Elapsed > TimeSpan.FromMinutes(RunParams.CHECKPOINT_MINIMUM_INTERVAL_MINUTES)) { _Logger.LogInfo("Saving checkpoint. Actual: [" + this.checkpointStopWatch.Elapsed + "] mins. minimum configured is : [" + RunParams.CHECKPOINT_MINIMUM_INTERVAL_MINUTES + "] mins"); await context.CheckpointAsync(); this.checkpointStopWatch.Restart(); } }