Share via


IEventProcessor Interface

Definition

Interface that must be implemented by event processor classes.

Any given instance of an event processor class will only process events from one partition of one Event Hub. A PartitionContext is provided with each call to the event processor because some parameters could change, but it will always be the same partition.

Although EventProcessorHost is multithreaded, calls to a given instance of an event processor class are serialized, except for OnError(). OnOpen() is called first, then OnEvents() will be called zero or more times. When the event processor needs to be shut down, whether because there was a failure somewhere, or the lease for the partition has been lost, or because the entire processor host is being shut down, OnClose() is called after the last OnEvents() call returns.

OnError() could be called while OnEvents() or OnClose() is executing. No synchronization is attempted in order to avoid possibly deadlocking.

public interface IEventProcessor
type IEventProcessor = interface
Public Interface IEventProcessor

Methods

CloseAsync(PartitionContext, CloseReason)

Called by processor host to indicate that the event processor is being stopped.

OpenAsync(PartitionContext)

Called by processor host to initialize the event processor.

ProcessErrorAsync(PartitionContext, Exception)

Called when the underlying client experiences an error while receiving. EventProcessorHost will take care of recovering from the error and continuing to pump messages, so no action is required from your code. This method is provided for informational purposes.

ProcessEventsAsync(PartitionContext, IEnumerable<EventData>)

Called by the processor host when a batch of events has arrived.

This is where the real work of the event processor is done.

Applies to