A client responsible for publishing EventData to a specific Event Hub, grouped together in batches. Depending on the options specified when sending, events data may be automatically routed to an available partition or sent to a specifically requested partition.
Inheritance
EventHubProducerClient
Namespace: Azure.Messaging.EventHubs.Producer
Assembly: Azure.Messaging.EventHubs.dll
Syntax
public class EventHubProducerClient : IAsyncDisposableConstructors
EventHubProducerClient()
Declaration
protected EventHubProducerClient ();EventHubProducerClient(String)
Declaration
public EventHubProducerClient (string connectionString);Parameters
| String connectionString The connection string to use for connecting to the Event Hubs namespace; it is expected that the Event Hub name and the shared key properties are contained in this connection string. |
EventHubProducerClient(EventHubConnection, EventHubProducerClientOptions)
Declaration
public EventHubProducerClient (Azure.Messaging.EventHubs.EventHubConnection connection, Azure.Messaging.EventHubs.Producer.EventHubProducerClientOptions clientOptions = null);Parameters
EventHubProducerClient(String, EventHubProducerClientOptions)
Declaration
public EventHubProducerClient (string connectionString, Azure.Messaging.EventHubs.Producer.EventHubProducerClientOptions clientOptions);Parameters
| String connectionString The connection string to use for connecting to the Event Hubs namespace; it is expected that the Event Hub name and the shared key properties are contained in this connection string. |
| EventHubProducerClientOptions clientOptions The set of options to use for this consumer. |
EventHubProducerClient(String, String)
Declaration
public EventHubProducerClient (string connectionString, string eventHubName);Parameters
| String connectionString The connection string to use for connecting to the Event Hubs namespace; it is expected that the shared key properties are contained in this connection string, but not the Event Hub name. |
| String eventHubName The name of the specific Event Hub to associate the producer with. |
EventHubProducerClient(String, String, EventHubProducerClientOptions)
Declaration
public EventHubProducerClient (string connectionString, string eventHubName, Azure.Messaging.EventHubs.Producer.EventHubProducerClientOptions clientOptions);Parameters
| String connectionString The connection string to use for connecting to the Event Hubs namespace; it is expected that the shared key properties are contained in this connection string, but not the Event Hub name. |
| String eventHubName The name of the specific Event Hub to associate the producer with. |
| EventHubProducerClientOptions clientOptions A set of options to apply when configuring the producer. |
EventHubProducerClient(String, String, TokenCredential, EventHubProducerClientOptions)
Declaration
public EventHubProducerClient (string fullyQualifiedNamespace, string eventHubName, Azure.Core.TokenCredential credential, Azure.Messaging.EventHubs.Producer.EventHubProducerClientOptions clientOptions = null);Parameters
| String fullyQualifiedNamespace The fully qualified Event Hubs namespace to connect to. This is likely to be similar to |
| String eventHubName The name of the specific Event Hub to associate the producer with. |
| TokenCredential credential The Azure managed identity credential to use for authorization. Access controls may be specified by the Event Hubs namespace or the requested Event Hub, depending on Azure configuration. |
| EventHubProducerClientOptions clientOptions A set of options to apply when configuring the producer. |
Properties
EventHubName
The name of the Event Hub that the producer is connected to, specific to the Event Hubs namespace that contains it.
Declaration
public string EventHubName { get; }Property Value
FullyQualifiedNamespace
The fully qualified Event Hubs namespace that the producer is associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net.
Declaration
public string FullyQualifiedNamespace { get; }Property Value
IsClosed
Declaration
public bool IsClosed { get; protected set; }Property Value
| Boolean
|
Methods
CloseAsync(CancellationToken)
Closes the producer.
Declaration
[System.Diagnostics.DebuggerStepThrough] public virtual System.Threading.Tasks.Task CloseAsync (System.Threading.CancellationToken cancellationToken = null);Parameters
Returns
| Task A task to be resolved on when the operation has completed. |
CreateBatchAsync(CancellationToken)
Creates a size-constraint batch to which EventData may be added using a try-based pattern. If an event would exceed the maximum allowable size of the batch, the batch will not allow adding the event and signal that scenario using its return value.
Because events that would violate the size constraint cannot be added, publishing a batch will not trigger an exception when attempting to send the events to the Event Hubs service.
Declaration
[System.Diagnostics.DebuggerStepThrough] public virtual System.Threading.Tasks.ValueTask<Azure.Messaging.EventHubs.Producer.EventDataBatch> CreateBatchAsync (System.Threading.CancellationToken cancellationToken = null);Parameters
Returns
See Also
CreateBatchAsync(CreateBatchOptions, CancellationToken)
Creates a size-constraint batch to which EventData may be added using a try-based pattern. If an event would exceed the maximum allowable size of the batch, the batch will not allow adding the event and signal that scenario using its return value.
Because events that would violate the size constraint cannot be added, publishing a batch will not trigger an exception when attempting to send the events to the Event Hubs service.
Declaration
[System.Diagnostics.DebuggerStepThrough] public virtual System.Threading.Tasks.ValueTask<Azure.Messaging.EventHubs.Producer.EventDataBatch> CreateBatchAsync (Azure.Messaging.EventHubs.Producer.CreateBatchOptions options, System.Threading.CancellationToken cancellationToken = null);Parameters
Returns
See Also
DisposeAsync()
Performs the task needed to clean up resources used by the EventHubProducerClient, including ensuring that the client itself has been closed.
Declaration
[System.Diagnostics.DebuggerStepThrough] public virtual System.Threading.Tasks.ValueTask DisposeAsync ();Returns
| ValueTask A task to be resolved on when the operation has completed. |
Equals(Object)
Determines whether the specified Object is equal to this instance.
Declaration
[System.ComponentModel.EditorBrowsable] public override bool Equals (object obj);Parameters
Returns
| Boolean
|
GetEventHubPropertiesAsync(CancellationToken)
Retrieves information about the Event Hub that the connection is associated with, including the number of partitions present and their identifiers.
Declaration
[System.Diagnostics.DebuggerStepThrough] public virtual System.Threading.Tasks.Task<Azure.Messaging.EventHubs.EventHubProperties> GetEventHubPropertiesAsync (System.Threading.CancellationToken cancellationToken = null);Parameters
Returns
GetHashCode()
Returns a hash code for this instance.
Declaration
[System.ComponentModel.EditorBrowsable] public override int GetHashCode ();Returns
| Int32 A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. |
GetPartitionIdsAsync(CancellationToken)
Retrieves the set of identifiers for the partitions of an Event Hub.
Declaration
[System.Diagnostics.DebuggerStepThrough] public virtual System.Threading.Tasks.Task<string[]> GetPartitionIdsAsync (System.Threading.CancellationToken cancellationToken = null);Parameters
Returns
| Task<String[]> The set of identifiers for the partitions within the Event Hub that this client is associated with. |
GetPartitionPropertiesAsync(String, CancellationToken)
Retrieves information about a specific partition for an Event Hub, including elements that describe the available events in the partition event stream.
Declaration
[System.Diagnostics.DebuggerStepThrough] public virtual System.Threading.Tasks.Task<Azure.Messaging.EventHubs.PartitionProperties> GetPartitionPropertiesAsync (string partitionId, System.Threading.CancellationToken cancellationToken = null);Parameters
| String partitionId The unique identifier of a partition associated with the Event Hub. |
| CancellationToken cancellationToken An optional CancellationToken instance to signal the request to cancel the operation. |
Returns
| Task<PartitionProperties> The set of information for the requested partition under the Event Hub this client is associated with. |
SendAsync(EventDataBatch, CancellationToken)
Sends a set of events to the associated Event Hub using a batched approach.
Declaration
[System.Diagnostics.DebuggerStepThrough] public virtual System.Threading.Tasks.Task SendAsync (Azure.Messaging.EventHubs.Producer.EventDataBatch eventBatch, System.Threading.CancellationToken cancellationToken = null);Parameters
Returns
| Task A task to be resolved on when the operation has completed. |
See Also
ToString()
Converts the instance to string representation.
Declaration
[System.ComponentModel.EditorBrowsable] public override string ToString ();Returns
ncG1vNJzZmiZqqq%2Fpr%2FDpJuom6Njr627wWeaqKqVY8SqusOorqxmnprBcHDWnplonJ%2Bpu6bAjnqxrqqVY5qmv9KanqKml2OSt7HNrX%2BumqNkgm99jWlkqaqVq7amw41qZpqomWSOu8HRnmWGnaOorqi1zaBlfq6Vo8GJwcGsZYmqn5nCpLHRaHizraKae46x0qyYoKGenHuGwsSnq4Gtkqh7kb7OnaycnaJjkrexza1%2FrpqAp7ylwcKeqXykmZq7tXrHraSl