IEventProcessor Interface
public interface IEventProcessor
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.
Method Summary
Modifier and Type | Method and Description |
---|---|
void |
onClose(PartitionContext context, CloseReason reason)
Called by processor host to indicate that the event processor is being stopped. If onClose fails, the exception is reported to the general exception notification handler set via EventProcessorOptions, if any, but is otherwise ignored. |
void |
onError(PartitionContext context, Throwable error)
Called when the underlying client experiences an error while receiving. EventProcessorHost will take care of recovering from the error and continuing to pump events, so no action is required from your code. This method is provided for informational purposes. |
void |
onEvents(PartitionContext context, Iterable<EventData> events)
Called by the processor host when a batch of events has arrived. This is where the real work of the event processor is done. It is normally called when one or more events have arrived. If the EventProcessorHost instance was set up with an EventProcessorOptions on which setInvokeProcessorAfterReceiveTimeout(true) has been called, then when a receive times out, onEvents will be called with an empty iterable. By default this option is false and receive timeouts do not cause a call to this method. |
void |
onOpen(PartitionContext context)
Called by processor host to initialize the event processor. If onOpen fails, this event processor host instance will give up ownership of the partition. |
Method Details
onClose
public void onClose(PartitionContext context, CloseReason reason)
Called by processor host to indicate that the event processor is being stopped.
If onClose fails, the exception is reported to the general exception notification handler set via EventProcessorOptions, if any, but is otherwise ignored.
Parameters:
Throws:
onError
public void onError(PartitionContext context, Throwable error)
Called when the underlying client experiences an error while receiving. EventProcessorHost will take care of recovering from the error and continuing to pump events, so no action is required from your code. This method is provided for informational purposes.
Parameters:
onEvents
public void onEvents(PartitionContext context, Iterable
Called by the processor host when a batch of events has arrived.
This is where the real work of the event processor is done. It is normally called when one or more events have arrived. If the EventProcessorHost instance was set up with an EventProcessorOptions on which setInvokeProcessorAfterReceiveTimeout(true) has been called, then when a receive times out, onEvents will be called with an empty iterable. By default this option is false and receive timeouts do not cause a call to this method.
Parameters:
Throws:
onOpen
public void onOpen(PartitionContext context)
Called by processor host to initialize the event processor.
If onOpen fails, this event processor host instance will give up ownership of the partition.
Parameters:
Throws:
Applies to
Azure SDK for Java
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for