PartitionReceiver Class
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.
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
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 |
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
Azure SDK for .NET