EventDataBatch interface

An interface representing a batch of events which can be used to send events to Event Hub.

To create the batch, use the createBatch() method on the EventHubProducerClient. To send the batch, use the sendBatch() method on the same client. To fill the batch, use the tryAdd() method on the batch itself.

Properties

count

Number of events added to the batch.

maxSizeInBytes

The maximum size of the batch, in bytes. The tryAdd function on the batch will return false if the event being added causes the size of the batch to exceed this limit. Use the createBatch() method on the EventHubProducerClient to set the maxSizeInBytes.

sizeInBytes

Size of the batch in bytes after the events added to it have been encoded into a single AMQP message.

Methods

tryAdd(EventData | AmqpAnnotatedMessage, TryAddOptions)

Adds an event to the batch if permitted by the batch's size limit. NOTE: Always remember to check the return value of this method, before calling it again for the next event.

Property Details

count

Number of events added to the batch.

count: number

Property Value

number

maxSizeInBytes

The maximum size of the batch, in bytes. The tryAdd function on the batch will return false if the event being added causes the size of the batch to exceed this limit. Use the createBatch() method on the EventHubProducerClient to set the maxSizeInBytes.

maxSizeInBytes: number

Property Value

number

sizeInBytes

Size of the batch in bytes after the events added to it have been encoded into a single AMQP message.

sizeInBytes: number

Property Value

number

Method Details

tryAdd(EventData | AmqpAnnotatedMessage, TryAddOptions)

Adds an event to the batch if permitted by the batch's size limit. NOTE: Always remember to check the return value of this method, before calling it again for the next event.

function tryAdd(eventData: EventData | AmqpAnnotatedMessage, options?: TryAddOptions): boolean

Parameters

eventData

EventData | AmqpAnnotatedMessage

An individual event data object or AmqpAnnotatedMessage.

options
TryAddOptions

Returns

boolean

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