共用方式為


EventDataBatch.TryAdd(EventData) Method

Definition

Tries to add an event data to the batch if permitted by the batch's size limit.

public bool TryAdd (Microsoft.ServiceBus.Messaging.EventData eventData);
member this.TryAdd : Microsoft.ServiceBus.Messaging.EventData -> bool
Public Function TryAdd (eventData As EventData) As Boolean

Parameters

eventData
EventData

The EventData to add.

Returns

A boolean value indicating if the event data has been added to the batch or not.

Exceptions

Thrown when the EventData is null.

Thrown when the batch is already disposed.

Remarks

This method checks the sizes of the batch, the EventData object and the specified limit to determine if the EventData object can be added. It does not perform other validations on the current batch and the EventData object. It is possible that the application may get exceptions from the send call if the batched EventData objects cannot be sent in a batch. For example, they contain different PartitionKey values. For an unknown buffer size (indicated by a -1 for MaxSize during construction) special handling is done: 1. Small messages are added up to a 256k limit, which will work for both "Basic" and "Standard" Event Hub namespace types. 2. If the first message is > 256k then it is allowed up to a 4MB maximum size with no further messages allowed. The SendBatch will fail if the EventHub namespace doesn't support that size.

Applies to