Currently we use the EventProcessorHost to consume data, and we want to test what will do if we got exception in the ProcessEventsAsync() method(below code), we didn’t handle the exception, will the EventHubHost will catch the exception, if yes, what will the Host do?
publicasyncTask ProcessEventsAsync(PartitionContext context, IEnumerable<EventData> events)
{
foreach (var eventData in events)
{
var content =Encoding.UTF8.GetString(eventData.GetBytes());
// For testing, throw exception manually
if (DateTime.Now.Second % 2 == 0)
{
Console.WriteLine("Throw an exception, current is {0}",DateTime.Now);
thrownewException("test");
}
Console.WriteLine("Get message: partitionId:{0}, message:{1}", context.Lease.PartitionId, content);
}
if (_checkpointStopWatch.Elapsed >TimeSpan.FromMinutes(5))
{
await context.CheckpointAsync();
lock (this)
{
_checkpointStopWatch.Reset();
}
}
}