Delen via


PartitionSender Class

Definition

This sender class is a logical representation of sending events to a specific EventHub partition. Do not use this class if you do not care about sending events to specific partitions, instead use SendAsync(EventData).

public sealed class PartitionSender : Microsoft.Azure.EventHubs.ClientEntity
type PartitionSender = class
    inherit ClientEntity
Public NotInheritable Class PartitionSender
Inherits ClientEntity
Inheritance
PartitionSender

Properties

ClientId

Gets the client ID.

(Inherited from ClientEntity)
EventHubClient

Gets the EventHubClient associated with this PartitionSender.

IsClosed

Returns a boolean representing whether client object is closed or not.

(Inherited from ClientEntity)
PartitionId

Gets the partition ID for this PartitionSender.

RegisteredPlugins

Gets a list of currently registered plugins for this Client.

(Inherited from ClientEntity)
RetryPolicy

Gets the RetryPolicy for the ClientEntity.

(Inherited from ClientEntity)

Methods

Close()

Closes the ClientEntity.

(Inherited from ClientEntity)
CloseAsync()

Closes and releases resources for the PartitionSender.

CreateBatch()

Creates a batch where event data objects can be added for later SendAsync call.

CreateBatch(BatchOptions)

Creates a batch where event data objects can be added for later SendAsync call.

OnRetryPolicyUpdate()

Derived entity to override for retry policy updates.

(Inherited from ClientEntity)
RegisterPlugin(EventHubsPlugin)

Registers a EventHubsPlugin to be used with this client.

(Inherited from ClientEntity)
SendAsync(EventData)

Send EventData to a specific EventHub partition. The target partition is pre-determined when this PartitionSender was created. This send pattern emphasizes data correlation over general availability and latency.

There are 3 ways to send to EventHubs, each exposed as a method (along with its sendBatch overload):

i. SendAsync(EventData) or SendAsync(IEnumerable<EventData>)

ii. SendAsync(EventData, String) or SendAsync(IEnumerable<EventData>, String)

iii. SendAsync(EventData) or SendAsync(IEnumerable<EventData>)

Use this type of send if:

a. The client wants to take direct control of distribution of data across partitions. In this case client is responsible for making sure there is at least one sender per event hub partition.

b. User cannot use partition key as a mean to direct events to specific partition, yet there is a need for data correlation with partitioning scheme.

SendAsync(EventDataBatch)

Send a batch of EventData in EventDataBatch.

SendAsync(IEnumerable<EventData>)

Send EventData to a specific EventHub partition. The targeted partition is pre-determined when this PartitionSender was created.

There are 3 ways to send to EventHubs, to understand this particular type of send refer to the overload SendAsync(EventData), which is the same type of send and is used to send single EventData.

Sending a batch of EventData's is useful in the following cases:

i. Efficient send - sending a batch of EventData maximizes the overall throughput by optimally using the number of sessions created to EventHubs' service.

ii. Sending multiple EventData's in a Transaction. To acheive ACID properties, the Gateway Service will forward all EventData's in the batch to a single EventHub partition.

ThrowIfClosed()

Throws an exception if client object is already closed.

(Inherited from ClientEntity)
UnregisterPlugin(String)

Unregisters a EventHubsPlugin.

(Inherited from ClientEntity)

Applies to

See also