Udostępnij za pośrednictwem


EventProcessorClient.OnProcessingErrorAsync Method

Definition

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

protected override System.Threading.Tasks.Task OnProcessingErrorAsync (Exception exception, Azure.Messaging.EventHubs.Primitives.EventProcessorPartition partition, string operationDescription, System.Threading.CancellationToken cancellationToken);
override this.OnProcessingErrorAsync : Exception * Azure.Messaging.EventHubs.Primitives.EventProcessorPartition * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Protected Overrides Function OnProcessingErrorAsync (exception As Exception, partition As EventProcessorPartition, operationDescription As String, cancellationToken As CancellationToken) As Task

Parameters

exception
Exception

The exception that occurred during operation of the event processor.

partition
EventProcessorPartition

The context of the partition associated with the error, if any; otherwise, null. This may only be initialized for members of EventProcessorPartition, depending on the point at which the error occurred.

operationDescription
String

A short textual description of the operation during which the exception occurred; intended to be informational only.

cancellationToken
CancellationToken

A CancellationToken instance to signal the request to cancel the processing. This is most likely to occur when the processor is shutting down.

Returns

Remarks

This error handler is invoked when there is an exception observed within the event processor itself; it is not invoked for exceptions in code that has been implemented to process events or other overrides and extension points that are not critical to the processor's operation. The event processor 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. The method may do so by calling Stop on the processor instance and then, if desired, calling Start on the processor.

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.

Applies to