Designing and configuring exception handling
Event Hubs' exceptions provide very clear information regarding the reason for errors. All EventHub issues throw an EventHubsException
exception object.
The EventHubsException
exception object contains the following information:
IsTransient
: This indicates whether the exceptions can be retried.Reason
: This indicates the actual reason for the exception. Some example reasons could include timeouts, exceeding quota limits, exceeding message sizes, client connection disconnects, and more.
Here is a simple example of how to catch exceptions in .NET:
try { // Process Events } catch (EventHubsException ex) where (ex.Reason == EventHubsException.FailureReason.MessageSizeExceeded) { // Take action for the oversize messages }
You can learn more about exception handling at https://docs.microsoft.com/en-us/azure/event-hubs/exceptions-dotnet.
Next, let's look at...