public static void LogEvent(ATMEvent e) { if (_events.Count < 1024) // Avoid unconstrained memory growth { _events.Add(e); } }
async Task IEventProcessor.ProcessEventsAsync(PartitionContext context, IEnumerable <EventData> messages) { foreach (EventData eventData in messages) { string data = Encoding.UTF8.GetString(eventData.GetBytes()); Debug.WriteLine(string.Format("Message received. Partition: '{0}', Data: '{1}'", context.Lease.PartitionId, data)); // Log the event ATMEvent e = JsonConvert.DeserializeObject <ATMEvent>(data); ATMEventAggregator.LogEvent(e); } if (this.checkpointStopWatch.Elapsed > TimeSpan.FromMinutes(5)) { await context.CheckpointAsync(); this.checkpointStopWatch.Restart(); } }