Quantcast
Channel: Service Bus forum
Viewing all articles
Browse latest Browse all 1916

What will do when got an unhandled exception from ProcessEventsAsync() method?

$
0
0

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();

               }

           }

       }


Viewing all articles
Browse latest Browse all 1916

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>