Options
All
  • Public
  • Public/Protected
  • All
Menu

Class EventDataBatch

Package version

A class representing a batch of events which can be passed to the send method of a EventProducer instance. This batch is ensured to be under the maximum message size supported by Azure Event Hubs service.

Use createBatch() method on the EventHubProducer to create an instance of EventDataBatch instead of using new EventDataBatch(). You can specify an upper limit for the size of the batch via options when calling createBatch().

Use the tryAdd function on the EventDataBatch to add events to the batch. This method will return false after the upper limit is reached, therefore check the result before calling tryAdd() again.

class

Hierarchy

  • EventDataBatch

Index

Accessors

batchMessage

  • get batchMessage(): Buffer | undefined
  • property

    Represents the single AMQP message which is the result of encoding all the events added into the EventDataBatch instance.

    This is not meant for the user to use directly.

    When the EventDataBatch instance is passed to the send() method on the EventHubProducer, this single batched AMQP message is what gets sent over the wire to the service.

    readonly

    Returns Buffer | undefined

count

  • get count(): number
  • property

    Number of events in the EventDataBatch instance.

    readonly

    Returns number

partitionKey

  • get partitionKey(): string | undefined
  • property

    The partitionKey set during EventDataBatch creation. This value is hashed to produce a partition assignment when the producer is created without a partitionId

    readonly

    Returns string | undefined

sizeInBytes

  • get sizeInBytes(): number
  • property

    Size of the EventDataBatch instance after the events added to it have been encoded into a single AMQP message.

    readonly

    Returns number

Methods

tryAdd

  • Tries to add an event data 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.

    Parameters

    Returns boolean

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

Generated using TypeDoc