Dela via


EventProcessorClient.ProcessErrorAsync Event

Definition

Performs the tasks needed when an unexpected exception occurs within the operation of the event processor infrastructure. Implementation is mandatory.

This error handler is invoked when there is an exception observed within the EventProcessorClient itself; it is not invoked for exceptions in code that has been implemented to process events or other event handlers and extension points that execute developer code. The EventProcessorClient will make every effort to recover from exceptions and continue processing. Should an exception that cannot be recovered from be encountered, the processor will attempt to forfeit ownership of all partitions that it was processing so that work may be redistributed.

The exceptions surfaced to this method may be fatal or non-fatal; because the processor may not be able to accurately predict whether an exception was fatal or whether its state was corrupted, this method has responsibility for making the determination as to whether processing should be terminated or restarted. If desired, this can be done safely by calling StopProcessingAsync(CancellationToken) and/or StartProcessingAsync(CancellationToken).

It is recommended that, for production scenarios, the decision be made by considering observations made by this error handler, the method invoked when initializing processing for a partition, and the method invoked when processing for a partition is stopped. Many developers will also include data from their monitoring platforms in this decision as well.

As with event processing, should an exception occur in the code for the error handler, the event processor will allow it to bubble and will not attempt to handle it in any way. Developers are strongly encouraged to take exception scenarios into account and guard against them using try/catch blocks and other means as appropriate.

public event Func<Azure.Messaging.EventHubs.Processor.ProcessErrorEventArgs,System.Threading.Tasks.Task> ProcessErrorAsync;
member this.ProcessErrorAsync : Func<Azure.Messaging.EventHubs.Processor.ProcessErrorEventArgs, System.Threading.Tasks.Task> 
Public Custom Event ProcessErrorAsync As Func(Of ProcessErrorEventArgs, Task) 

Event Type

Exceptions

If an attempt is made to remove a handler that doesn't match the current handler registered.

If an attempt is made to add a handler when one is currently registered.

Remarks

This handler will be invoked concurrently and is not awaited by the processor, as each error is independent. No time limit is imposed on an invocation of this handler; it is safe for implementations to perform long-running operations and retries as needed.

Applies to

See also