Share via


EventHubConsumerClient.ReadEventsFromPartitionAsync Method

Definition

Overloads

ReadEventsFromPartitionAsync(String, EventPosition, CancellationToken)

Reads events from the requested partition as an asynchronous enumerable, allowing events to be iterated as they become available on the partition, waiting as necessary should there be no events available.

This enumerator may block for an indeterminate amount of time for an await if events are not available on the partition, requiring cancellation via the cancellationToken to be requested in order to return control. It is recommended to call the overload which accepts a set of options for configuring read behavior for scenarios where a more deterministic maximum waiting period is desired.

ReadEventsFromPartitionAsync(String, EventPosition, ReadEventOptions, CancellationToken)

Reads events from the requested partition as an asynchronous enumerable, allowing events to be iterated as they become available on the partition, waiting as necessary should there be no events available.

This enumerator may block for an indeterminate amount of time for an await if events are not available on the partition, requiring cancellation via the cancellationToken to be requested in order to return control. It is recommended to set the MaximumWaitTime for scenarios where a more deterministic maximum waiting period is desired.

ReadEventsFromPartitionAsync(String, EventPosition, CancellationToken)

Source:
EventHubConsumerClient.cs
Source:
EventHubConsumerClient.cs

Reads events from the requested partition as an asynchronous enumerable, allowing events to be iterated as they become available on the partition, waiting as necessary should there be no events available.

This enumerator may block for an indeterminate amount of time for an await if events are not available on the partition, requiring cancellation via the cancellationToken to be requested in order to return control. It is recommended to call the overload which accepts a set of options for configuring read behavior for scenarios where a more deterministic maximum waiting period is desired.

public virtual System.Collections.Generic.IAsyncEnumerable<Azure.Messaging.EventHubs.Consumer.PartitionEvent> ReadEventsFromPartitionAsync (string partitionId, Azure.Messaging.EventHubs.Consumer.EventPosition startingPosition, System.Threading.CancellationToken cancellationToken = default);
abstract member ReadEventsFromPartitionAsync : string * Azure.Messaging.EventHubs.Consumer.EventPosition * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Azure.Messaging.EventHubs.Consumer.PartitionEvent>
override this.ReadEventsFromPartitionAsync : string * Azure.Messaging.EventHubs.Consumer.EventPosition * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Azure.Messaging.EventHubs.Consumer.PartitionEvent>
Public Overridable Function ReadEventsFromPartitionAsync (partitionId As String, startingPosition As EventPosition, Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of PartitionEvent)

Parameters

partitionId
String

The identifier of the Event Hub partition from which events will be received.

startingPosition
EventPosition

The position within the partition where the consumer should begin reading events.

cancellationToken
CancellationToken

An optional CancellationToken instance to signal the request to cancel the operation.

Returns

An IAsyncEnumerable<T> to be used for iterating over events in the partition.

Exceptions

Occurs when an EventHubConsumerClient 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

Each reader of events is presented with an independent iterator; if there are multiple readers, each receive their own copy of an event to process, rather than competing for them.

See also

Applies to

ReadEventsFromPartitionAsync(String, EventPosition, ReadEventOptions, CancellationToken)

Source:
EventHubConsumerClient.cs
Source:
EventHubConsumerClient.cs

Reads events from the requested partition as an asynchronous enumerable, allowing events to be iterated as they become available on the partition, waiting as necessary should there be no events available.

This enumerator may block for an indeterminate amount of time for an await if events are not available on the partition, requiring cancellation via the cancellationToken to be requested in order to return control. It is recommended to set the MaximumWaitTime for scenarios where a more deterministic maximum waiting period is desired.

public virtual System.Collections.Generic.IAsyncEnumerable<Azure.Messaging.EventHubs.Consumer.PartitionEvent> ReadEventsFromPartitionAsync (string partitionId, Azure.Messaging.EventHubs.Consumer.EventPosition startingPosition, Azure.Messaging.EventHubs.Consumer.ReadEventOptions readOptions, System.Threading.CancellationToken cancellationToken = default);
abstract member ReadEventsFromPartitionAsync : string * Azure.Messaging.EventHubs.Consumer.EventPosition * Azure.Messaging.EventHubs.Consumer.ReadEventOptions * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Azure.Messaging.EventHubs.Consumer.PartitionEvent>
override this.ReadEventsFromPartitionAsync : string * Azure.Messaging.EventHubs.Consumer.EventPosition * Azure.Messaging.EventHubs.Consumer.ReadEventOptions * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Azure.Messaging.EventHubs.Consumer.PartitionEvent>
Public Overridable Function ReadEventsFromPartitionAsync (partitionId As String, startingPosition As EventPosition, readOptions As ReadEventOptions, Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of PartitionEvent)

Parameters

partitionId
String

The identifier of the Event Hub partition from which events will be received.

startingPosition
EventPosition

The position within the partition where the consumer should begin reading events.

readOptions
ReadEventOptions

The set of options to use for configuring read behavior; if not specified the defaults will be used.

cancellationToken
CancellationToken

An optional CancellationToken instance to signal the request to cancel the operation.

Returns

An IAsyncEnumerable<T> to be used for iterating over events in the partition.

Exceptions

Occurs when an EventHubConsumerClient 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

Each reader of events is presented with an independent iterator; if there are multiple readers, each receive their own copy of an event to process, rather than competing for them.

See also

Applies to