private async Task ProcessEventsAsync(PartitionContext context, EventData[] messages, int retries) { try { var tasks = new List <Task <bool> >(); var actorRef = _actorSystem.ActorSelection("akka://user/akka-iot-ingress"); foreach (var eventData in messages) { tasks.Add(actorRef.Ask <bool>(new IngressActor.DispatchEventData { EventData = eventData, PartitionId = context.PartitionId })); } var success = await Task.WhenAll(tasks); if (!success.All(s => s)) { throw new Exception("At least one message could not be processed"); } await _tableStorage.CompleteBatch(context.PartitionId); await Checkpoint(context); } catch (Exception e) { Console.WriteLine(e); if (retries > 0) { await ProcessEventsAsync(context, messages, retries - 1); } else { throw; } } }