EventProcessorClient.OnProcessingEventBatchAsync(IEnumerable<EventData>, EventProcessorPartition, CancellationToken) Method


Performs the tasks needed to process a batch of events for a given partition as they are read from the Event Hubs service.

protected override System.Threading.Tasks.Task OnProcessingEventBatchAsync (System.Collections.Generic.IEnumerable<Azure.Messaging.EventHubs.EventData> events, Azure.Messaging.EventHubs.Primitives.EventProcessorPartition partition, System.Threading.CancellationToken cancellationToken);
override this.OnProcessingEventBatchAsync : seq<Azure.Messaging.EventHubs.EventData> * Azure.Messaging.EventHubs.Primitives.EventProcessorPartition * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Protected Overrides Function OnProcessingEventBatchAsync (events As IEnumerable(Of EventData), partition As EventProcessorPartition, cancellationToken As CancellationToken) As Task



The batch of events to be processed.


The context of the partition from which the events were read.


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




The number of events in the events batch may vary. The batch will contain a number of events between zero and batch size that was requested when the processor was created, depending on the availability of events in the partition within the requested MaximumWaitTime interval.

 If there are enough events available in the Event Hub partition to fill a batch of the requested size, the processor will populate the batch and dispatch it to this method
 immediately.  If there were not a sufficient number of events available in the partition to populate a full batch, the event processor will continue reading from the partition
 to reach the requested batch size until the <xref data-throw-if-not-resolved="true" uid="Azure.Messaging.EventHubs.Primitives.EventProcessorOptions.MaximumWaitTime"></xref> has elapsed, at which point it will return a batch containing whatever events were
 available by the end of that period.

 If a <xref data-throw-if-not-resolved="true" uid="Azure.Messaging.EventHubs.Primitives.EventProcessorOptions.MaximumWaitTime"></xref> was not requested, indicated by setting the option to <code data-dev-comment-type="c">null</code>, the event processor will continue reading from the Event Hub
 partition until a full batch of the requested size could be populated and will not dispatch any partial batches to this method.</p>

Should an exception occur within the code for this method, the event processor will allow it to bubble and will not surface to the error handler or 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.

It is not recommended that the state of the processor be managed directly from within this method; requesting to start or stop the processor may result in a deadlock scenario, especially if using the synchronous form of the call.

Applies to