Sdílet prostřednictvím


PartitionReceiver Class

Definition

Allows reading events from a specific partition of an Event Hub, and in the context of a specific consumer group, to be read with a greater level of control over communication with the Event Hubs service than is offered by other event consumers.

public class PartitionReceiver : IAsyncDisposable
type PartitionReceiver = class
    interface IAsyncDisposable
Public Class PartitionReceiver
Implements IAsyncDisposable
Inheritance
PartitionReceiver
Implements

Remarks

It is recommended that the EventProcessorClient or EventHubConsumerClient be used for reading and processing events for the majority of scenarios. The partition receiver is intended to enable scenarios with special needs which require more direct control.

The PartitionReceiver is safe to cache and use for the lifetime of an application, and which is the best practice when the application reads events regularly or semi-regularly. The receiver is responsible for ensuring efficient network, CPU, and memory use. Calling either CloseAsync(CancellationToken) or DisposeAsync() as the application is shutting down will ensure that network resources and other unmanaged objects are properly cleaned up.

Constructors

PartitionReceiver()

Initializes a new instance of the PartitionReceiver class.

PartitionReceiver(String, String, EventPosition, EventHubConnection, PartitionReceiverOptions)

Initializes a new instance of the PartitionReceiver class.

PartitionReceiver(String, String, EventPosition, String, PartitionReceiverOptions)

Initializes a new instance of the PartitionReceiver class.

PartitionReceiver(String, String, EventPosition, String, String, AzureNamedKeyCredential, PartitionReceiverOptions)

Initializes a new instance of the PartitionReceiver class.

PartitionReceiver(String, String, EventPosition, String, String, AzureSasCredential, PartitionReceiverOptions)

Initializes a new instance of the PartitionReceiver class.

PartitionReceiver(String, String, EventPosition, String, String, PartitionReceiverOptions)

Initializes a new instance of the PartitionReceiver class.

PartitionReceiver(String, String, EventPosition, String, String, TokenCredential, PartitionReceiverOptions)

Initializes a new instance of the PartitionReceiver class.

Properties

ConsumerGroup

The name of the consumer group that this client is associated with. Events will be read only in the context of this group.

EventHubName

The name of the Event Hub that the client is connected to, specific to the Event Hubs namespace that contains it.

FullyQualifiedNamespace

The fully qualified Event Hubs namespace that the client is associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net.

Identifier

A unique name used to identify this receiver.

InitialPosition

The position within the partition where the client begins reading events.

IsClosed

Indicates whether or not this PartitionReceiver has been closed.

PartitionId

The identifier of the Event Hub partition that this client is associated with. Events will be read only from this partition.

Methods

CloseAsync(CancellationToken)

Closes the client.

DisposeAsync()

Performs the task needed to clean up resources used by the PartitionReceiver, including ensuring that the client itself has been closed.

GetPartitionPropertiesAsync(CancellationToken)

Retrieves information about the partition this client is associated to, including elements that describe the available events in the partition event stream.

ReadLastEnqueuedEventProperties()

A set of information about the last enqueued event of the partition associated with this receiver, observed as events are received from the Event Hubs service. This is only available if the receiver was created with TrackLastEnqueuedEventProperties set. Otherwise, the properties will contain default values.

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.

Applies to

See also