xml/Microsoft.Azure.EventHubs/PartitionSender.xml (251 lines of code) (raw):
<Type Name="PartitionSender" FullName="Microsoft.Azure.EventHubs.PartitionSender">
<TypeSignature Language="C#" Value="public sealed class PartitionSender : Microsoft.Azure.EventHubs.ClientEntity" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit PartitionSender extends Microsoft.Azure.EventHubs.ClientEntity" />
<TypeSignature Language="DocId" Value="T:Microsoft.Azure.EventHubs.PartitionSender" />
<TypeSignature Language="VB.NET" Value="Public NotInheritable Class PartitionSender
Inherits ClientEntity" />
<TypeSignature Language="F#" Value="type PartitionSender = class
 inherit ClientEntity" />
<AssemblyInfo>
<AssemblyName>Microsoft.Azure.EventHubs</AssemblyName>
<AssemblyVersion>4.3.1.0</AssemblyVersion>
<AssemblyVersion>4.3.2.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>Microsoft.Azure.EventHubs.ClientEntity</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>
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 <see cref="M:Microsoft.Azure.EventHubs.EventHubClient.SendAsync(Microsoft.Azure.EventHubs.EventData)" />.
</summary>
<remarks>To be added.</remarks>
<altmember cref="M:Microsoft.Azure.EventHubs.EventHubClient.CreatePartitionSender(System.String)" />
<altmember cref="M:Microsoft.Azure.EventHubs.EventHubClient.CreateFromConnectionString(System.String)" />
</Docs>
<Members>
<Member MemberName="CloseAsync">
<MemberSignature Language="C#" Value="public override System.Threading.Tasks.Task CloseAsync ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance class System.Threading.Tasks.Task CloseAsync() cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.Azure.EventHubs.PartitionSender.CloseAsync" />
<MemberSignature Language="VB.NET" Value="Public Overrides Function CloseAsync () As Task" />
<MemberSignature Language="F#" Value="override this.CloseAsync : unit -> System.Threading.Tasks.Task" Usage="partitionSender.CloseAsync " />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.Azure.EventHubs</AssemblyName>
<AssemblyVersion>4.3.2.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Threading.Tasks.Task</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>
Closes and releases resources for the <see cref="T:Microsoft.Azure.EventHubs.PartitionSender" />.
</summary>
<returns>An asynchronous operation</returns>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="CreateBatch">
<MemberSignature Language="C#" Value="public Microsoft.Azure.EventHubs.EventDataBatch CreateBatch ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Microsoft.Azure.EventHubs.EventDataBatch CreateBatch() cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.Azure.EventHubs.PartitionSender.CreateBatch" />
<MemberSignature Language="VB.NET" Value="Public Function CreateBatch () As EventDataBatch" />
<MemberSignature Language="F#" Value="member this.CreateBatch : unit -> Microsoft.Azure.EventHubs.EventDataBatch" Usage="partitionSender.CreateBatch " />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.Azure.EventHubs</AssemblyName>
<AssemblyVersion>4.3.2.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>Microsoft.Azure.EventHubs.EventDataBatch</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Creates a batch where event data objects can be added for later SendAsync call.</summary>
<returns>Returns <see cref="T:Microsoft.Azure.EventHubs.EventDataBatch" />.</returns>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="CreateBatch">
<MemberSignature Language="C#" Value="public Microsoft.Azure.EventHubs.EventDataBatch CreateBatch (Microsoft.Azure.EventHubs.BatchOptions options);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class Microsoft.Azure.EventHubs.EventDataBatch CreateBatch(class Microsoft.Azure.EventHubs.BatchOptions options) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.Azure.EventHubs.PartitionSender.CreateBatch(Microsoft.Azure.EventHubs.BatchOptions)" />
<MemberSignature Language="VB.NET" Value="Public Function CreateBatch (options As BatchOptions) As EventDataBatch" />
<MemberSignature Language="F#" Value="member this.CreateBatch : Microsoft.Azure.EventHubs.BatchOptions -> Microsoft.Azure.EventHubs.EventDataBatch" Usage="partitionSender.CreateBatch options" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.Azure.EventHubs</AssemblyName>
<AssemblyVersion>4.3.2.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>Microsoft.Azure.EventHubs.EventDataBatch</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="options" Type="Microsoft.Azure.EventHubs.BatchOptions" />
</Parameters>
<Docs>
<param name="options">
<see cref="T:Microsoft.Azure.EventHubs.BatchOptions" /> to define partition key and max message size.</param>
<summary>Creates a batch where event data objects can be added for later SendAsync call.</summary>
<returns>Returns <see cref="T:Microsoft.Azure.EventHubs.EventDataBatch" />.</returns>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="EventHubClient">
<MemberSignature Language="C#" Value="public Microsoft.Azure.EventHubs.EventHubClient EventHubClient { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class Microsoft.Azure.EventHubs.EventHubClient EventHubClient" />
<MemberSignature Language="DocId" Value="P:Microsoft.Azure.EventHubs.PartitionSender.EventHubClient" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property EventHubClient As EventHubClient" />
<MemberSignature Language="F#" Value="member this.EventHubClient : Microsoft.Azure.EventHubs.EventHubClient" Usage="Microsoft.Azure.EventHubs.PartitionSender.EventHubClient" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.Azure.EventHubs</AssemblyName>
<AssemblyVersion>4.3.2.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>Microsoft.Azure.EventHubs.EventHubClient</ReturnType>
</ReturnValue>
<Docs>
<summary>
Gets the <see cref="P:Microsoft.Azure.EventHubs.PartitionSender.EventHubClient" /> associated with this PartitionSender.
</summary>
<value>To be added.</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="PartitionId">
<MemberSignature Language="C#" Value="public string PartitionId { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance string PartitionId" />
<MemberSignature Language="DocId" Value="P:Microsoft.Azure.EventHubs.PartitionSender.PartitionId" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property PartitionId As String" />
<MemberSignature Language="F#" Value="member this.PartitionId : string" Usage="Microsoft.Azure.EventHubs.PartitionSender.PartitionId" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.Azure.EventHubs</AssemblyName>
<AssemblyVersion>4.3.2.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>
Gets the partition ID for this <see cref="T:Microsoft.Azure.EventHubs.PartitionSender" />.
</summary>
<value>To be added.</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="SendAsync">
<MemberSignature Language="C#" Value="public System.Threading.Tasks.Task SendAsync (Microsoft.Azure.EventHubs.EventData eventData);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.Threading.Tasks.Task SendAsync(class Microsoft.Azure.EventHubs.EventData eventData) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.Azure.EventHubs.PartitionSender.SendAsync(Microsoft.Azure.EventHubs.EventData)" />
<MemberSignature Language="VB.NET" Value="Public Function SendAsync (eventData As EventData) As Task" />
<MemberSignature Language="F#" Value="member this.SendAsync : Microsoft.Azure.EventHubs.EventData -> System.Threading.Tasks.Task" Usage="partitionSender.SendAsync eventData" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.Azure.EventHubs</AssemblyName>
<AssemblyVersion>4.3.2.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Threading.Tasks.Task</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="eventData" Type="Microsoft.Azure.EventHubs.EventData" />
</Parameters>
<Docs>
<param name="eventData">the <see cref="T:Microsoft.Azure.EventHubs.EventData" /> to be sent.</param>
<summary>
Send <see cref="T:Microsoft.Azure.EventHubs.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.
<para>There are 3 ways to send to EventHubs, each exposed as a method (along with its sendBatch overload):</para><para>i. <see cref="M:Microsoft.Azure.EventHubs.EventHubClient.SendAsync(Microsoft.Azure.EventHubs.EventData)" /> or <see cref="M:Microsoft.Azure.EventHubs.EventHubClient.SendAsync(System.Collections.Generic.IEnumerable{Microsoft.Azure.EventHubs.EventData})" /></para><para>ii. <see cref="M:Microsoft.Azure.EventHubs.EventHubClient.SendAsync(Microsoft.Azure.EventHubs.EventData,System.String)" /> or <see cref="M:Microsoft.Azure.EventHubs.EventHubClient.SendAsync(System.Collections.Generic.IEnumerable{Microsoft.Azure.EventHubs.EventData},System.String)" /></para><para>iii. <see cref="M:Microsoft.Azure.EventHubs.PartitionSender.SendAsync(Microsoft.Azure.EventHubs.EventData)" /> or <see cref="M:Microsoft.Azure.EventHubs.PartitionSender.SendAsync(System.Collections.Generic.IEnumerable{Microsoft.Azure.EventHubs.EventData})" /></para>
Use this type of send if:
<para>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.</para><para>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.</para></summary>
<returns>A Task that completes when the send operations is done.</returns>
<remarks>To be added.</remarks>
<exception cref="T:Microsoft.Azure.EventHubs.MessageSizeExceededException">the total size of the <see cref="T:Microsoft.Azure.EventHubs.EventData" /> exceeds a pre-defined limit set by the service. Default is 256k bytes.</exception>
<exception cref="T:Microsoft.Azure.EventHubs.EventHubsException">Event Hubs service encountered problems during the operation.</exception>
</Docs>
</Member>
<Member MemberName="SendAsync">
<MemberSignature Language="C#" Value="public System.Threading.Tasks.Task SendAsync (Microsoft.Azure.EventHubs.EventDataBatch eventDataBatch);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.Threading.Tasks.Task SendAsync(class Microsoft.Azure.EventHubs.EventDataBatch eventDataBatch) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.Azure.EventHubs.PartitionSender.SendAsync(Microsoft.Azure.EventHubs.EventDataBatch)" />
<MemberSignature Language="VB.NET" Value="Public Function SendAsync (eventDataBatch As EventDataBatch) As Task" />
<MemberSignature Language="F#" Value="member this.SendAsync : Microsoft.Azure.EventHubs.EventDataBatch -> System.Threading.Tasks.Task" Usage="partitionSender.SendAsync eventDataBatch" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.Azure.EventHubs</AssemblyName>
<AssemblyVersion>4.3.2.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Threading.Tasks.Task</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="eventDataBatch" Type="Microsoft.Azure.EventHubs.EventDataBatch" />
</Parameters>
<Docs>
<param name="eventDataBatch">the batch of events to send to EventHub</param>
<summary>
Send a batch of <see cref="T:Microsoft.Azure.EventHubs.EventData" /> in <see cref="T:Microsoft.Azure.EventHubs.EventDataBatch" />.
</summary>
<returns>A Task that completes when the send operation is done.</returns>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="SendAsync">
<MemberSignature Language="C#" Value="public System.Threading.Tasks.Task SendAsync (System.Collections.Generic.IEnumerable<Microsoft.Azure.EventHubs.EventData> eventDatas);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.Threading.Tasks.Task SendAsync(class System.Collections.Generic.IEnumerable`1<class Microsoft.Azure.EventHubs.EventData> eventDatas) cil managed" />
<MemberSignature Language="DocId" Value="M:Microsoft.Azure.EventHubs.PartitionSender.SendAsync(System.Collections.Generic.IEnumerable{Microsoft.Azure.EventHubs.EventData})" />
<MemberSignature Language="VB.NET" Value="Public Function SendAsync (eventDatas As IEnumerable(Of EventData)) As Task" />
<MemberSignature Language="F#" Value="member this.SendAsync : seq<Microsoft.Azure.EventHubs.EventData> -> System.Threading.Tasks.Task" Usage="partitionSender.SendAsync eventDatas" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Microsoft.Azure.EventHubs</AssemblyName>
<AssemblyVersion>4.3.2.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Threading.Tasks.Task</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="eventDatas" Type="System.Collections.Generic.IEnumerable<Microsoft.Azure.EventHubs.EventData>" />
</Parameters>
<Docs>
<param name="eventDatas">batch of events to send to EventHub</param>
<summary>
Send <see cref="T:Microsoft.Azure.EventHubs.EventData" /> to a specific EventHub partition. The targeted partition is pre-determined when this PartitionSender was created.
<para>
There are 3 ways to send to EventHubs, to understand this particular type of send refer to the overload <see cref="M:Microsoft.Azure.EventHubs.PartitionSender.SendAsync(Microsoft.Azure.EventHubs.EventData)" />, which is the same type of send and is used to send single <see cref="T:Microsoft.Azure.EventHubs.EventData" />.
</para>
Sending a batch of <see cref="T:Microsoft.Azure.EventHubs.EventData" />'s is useful in the following cases:
<para>i. Efficient send - sending a batch of <see cref="T:Microsoft.Azure.EventHubs.EventData" /> maximizes the overall throughput by optimally using the number of sessions created to EventHubs' service.</para><para>ii. Sending multiple <see cref="T:Microsoft.Azure.EventHubs.EventData" />'s in a Transaction. To acheive ACID properties, the Gateway Service will forward all <see cref="T:Microsoft.Azure.EventHubs.EventData" />'s in the batch to a single EventHub partition.</para></summary>
<returns>a Task that completes when the send operation is done.</returns>
<remarks>To be added.</remarks>
<example>
Sample code:
<code>
EventHubClient client = EventHubClient.Create("__connectionString__");
PartitionSender senderToPartitionOne = client.CreatePartitionSender("1");
while (true)
{
var events = new List<EventData>();
for (int count = 1; count < 11; count++)
{
var payload = new PayloadEvent(count);
byte[] payloadBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(payload));
var sendEvent = new EventData(payloadBytes);
var applicationProperties = new Dictionary<string, string>();
applicationProperties["from"] = "csharpClient";
sendEvent.Properties = applicationProperties;
events.Add(sendEvent);
}
await senderToPartitionOne.SendAsync(events);
Console.WriteLine("Sent Batch... Size: {0}", events.Count);
}
</code></example>
<exception cref="T:Microsoft.Azure.EventHubs.MessageSizeExceededException">the total size of the <see cref="T:Microsoft.Azure.EventHubs.EventData" /> exceeds a pre-defined limit set by the service. Default is 256k bytes.</exception>
<exception cref="T:Microsoft.Azure.EventHubs.EventHubsException">Event Hubs service encountered problems during the operation.</exception>
</Docs>
</Member>
</Members>
</Type>