Interface IEventProcessor
- Namespace
- Microsoft.ServiceBus.Messaging
- Assembly
- Microsoft.ServiceBus.dll
Provides methods for event processors. Applications must implement this interface, which enables the handling of events from Event Hubs. This interface is the main extensibility point for the Microsoft.ServiceBus.Messaging.EventProcessorHost and RegisterProcessor<T>(Lease, ICheckpointManager).
public interface IEventProcessor
Methods
CloseAsync(PartitionContext, CloseReason)
Called when the ownership of partition moves to a different node for load-balancing purpose, or when the host is shutting down. Called in response to UnregisterProcessorAsync(Lease, CloseReason).
Task CloseAsync(PartitionContext context, CloseReason reason)
Parameters
context
PartitionContextPartition ownership information for the partition on which this processor instance works. You can call CheckpointAsync() to checkpoint progress in the processing of messages from Event Hub streams.
reason
CloseReasonThe reason for calling CloseAsync(PartitionContext, CloseReason).
Returns
- Task
A task indicating that the Close operation is complete.
OpenAsync(PartitionContext)
Initializes the Event Hub processor instance. This method is called before any event data is passed to this processor instance.
Task OpenAsync(PartitionContext context)
Parameters
context
PartitionContextOwnership information for the partition on which this processor instance works. Any attempt to call CheckpointAsync() will fail during the Open operation.
Returns
- Task
The task that indicates that the Open operation is complete.
ProcessEventsAsync(PartitionContext, IEnumerable<EventData>)
Asynchronously processes the specified context and messages. This method is called when there are new messages in the Event Hubs stream. Make sure to checkpoint only when you are finished processing all the events in each batch.
Task ProcessEventsAsync(PartitionContext context, IEnumerable<EventData> messages)
Parameters
context
PartitionContextOwnership information for the partition on which this processor instance works.
messages
IEnumerable<EventData>A batch of Event Hubs events.
Returns
- Task
The task that indicates that ProcessEventsAsync(PartitionContext, IEnumerable<EventData>) is complete.