PartitionReceiver.ReceiveBatchAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
ReceiveBatchAsync(Int32, CancellationToken) |
Receives a batch of EventData from the Event Hub partition this client is associated with. |
ReceiveBatchAsync(Int32, TimeSpan, CancellationToken) |
Receives a batch of EventData from the Event Hub partition this client is associated with. |
ReceiveBatchAsync(Int32, CancellationToken)
- Source:
- PartitionReceiver.cs
- Source:
- PartitionReceiver.cs
Receives a batch of EventData from the Event Hub partition this client is associated with.
public virtual System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<Azure.Messaging.EventHubs.EventData>> ReceiveBatchAsync (int maximumEventCount, System.Threading.CancellationToken cancellationToken = default);
abstract member ReceiveBatchAsync : int * System.Threading.CancellationToken -> System.Threading.Tasks.Task<seq<Azure.Messaging.EventHubs.EventData>>
override this.ReceiveBatchAsync : int * System.Threading.CancellationToken -> System.Threading.Tasks.Task<seq<Azure.Messaging.EventHubs.EventData>>
Public Overridable Function ReceiveBatchAsync (maximumEventCount As Integer, Optional cancellationToken As CancellationToken = Nothing) As Task(Of IEnumerable(Of EventData))
Parameters
- maximumEventCount
- Int32
The maximum number of messages to receive in this batch.
- cancellationToken
- CancellationToken
An optional CancellationToken instance to signal the request to cancel the operation.
Returns
The batch of EventData from the Event Hub partition this client is associated with. If no events are present, an empty enumerable is returned.
Exceptions
Occurs when the requested maximumEventCount
is less than 1.
Occurs when an PartitionReceiver is unable to read from the requested Event Hub partition due to another reader having asserted exclusive ownership. In this case, the EventHubsException.FailureReason will be set to ConsumerDisconnected.
Remarks
When events are available in the prefetch queue, they will be used to form the batch as quickly as possible without waiting for additional events from the Event Hubs service to try and meet the requested maximumEventCount
. When no events are available in prefetch, the receiver will wait up to the duration specified by the TryTimeout in the active retry policy for events to be read from the service. Once any events are available, they will be used to form the batch immediately.
Applies to
ReceiveBatchAsync(Int32, TimeSpan, CancellationToken)
- Source:
- PartitionReceiver.cs
- Source:
- PartitionReceiver.cs
Receives a batch of EventData from the Event Hub partition this client is associated with.
public virtual System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<Azure.Messaging.EventHubs.EventData>> ReceiveBatchAsync (int maximumEventCount, TimeSpan maximumWaitTime, System.Threading.CancellationToken cancellationToken = default);
abstract member ReceiveBatchAsync : int * TimeSpan * System.Threading.CancellationToken -> System.Threading.Tasks.Task<seq<Azure.Messaging.EventHubs.EventData>>
override this.ReceiveBatchAsync : int * TimeSpan * System.Threading.CancellationToken -> System.Threading.Tasks.Task<seq<Azure.Messaging.EventHubs.EventData>>
Public Overridable Function ReceiveBatchAsync (maximumEventCount As Integer, maximumWaitTime As TimeSpan, Optional cancellationToken As CancellationToken = Nothing) As Task(Of IEnumerable(Of EventData))
Parameters
- maximumEventCount
- Int32
The maximum number of messages to receive in this batch.
- maximumWaitTime
- TimeSpan
The maximum amount of time to wait for events to become available, if no events can be read from the prefetch queue.
- cancellationToken
- CancellationToken
An optional CancellationToken instance to signal the request to cancel the operation.
Returns
The batch of EventData from the Event Hub partition this client is associated with. If no events are present, an empty enumerable is returned.
Exceptions
Occurs when the requested maximumEventCount
is less than 1.
Occurs when an PartitionReceiver is unable to read from the requested Event Hub partition due to another reader having asserted exclusive ownership. In this case, the EventHubsException.FailureReason will be set to ConsumerDisconnected.
Remarks
When events are available in the prefetch queue, they will be used to form the batch as quickly as possible without waiting for additional events from the Event Hubs service to try and meet the requested maximumEventCount
. When no events are available in prefetch, the receiver will wait up to the maximumWaitTime
for events to be read from the service. Once any events are available, they will be used to form the batch immediately.
Applies to
Azure SDK for .NET