Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ServiceBusSender

Package version

A Sender can be used to send messages, schedule messages to be sent at a later time and cancel such scheduled messages. Use the createSender function on the ServiceBusClient instantiate a Sender. The Sender class is an abstraction over the underlying AMQP sender link.

Hierarchy

  • ServiceBusSender

Index

Properties

entityPath

entityPath: string

Path of the entity for which the sender has been created.

isClosed

isClosed: boolean
property

Returns true if either the sender or the client that created it has been closed

readonly

Methods

cancelScheduledMessages

  • cancelScheduledMessages(sequenceNumbers: Long | Long[], options?: OperationOptionsBase): Promise<void>
  • Cancels multiple messages that were scheduled to appear on a ServiceBus Queue/Subscription.

    throws

    Error if the underlying connection, client or sender is closed.

    throws

    MessagingError if the service returns an error while canceling scheduled messages.

    Parameters

    • sequenceNumbers: Long | Long[]

      Sequence number or an array of sequence numbers of the messages to be cancelled.

    • Optional options: OperationOptionsBase

      Options bag to pass an abort signal or tracing options.

    Returns Promise<void>

    Promise

close

  • close(): Promise<void>

createBatch

  • Creates an instance of ServiceBusMessageBatch to which one can add messages until the maximum supported size is reached. The batch can be passed to the {@link send} method to send the messages to Azure Service Bus.

    throws

    MessagingError if an error is encountered while sending a message.

    throws

    Error if the underlying connection or sender has been closed.

    Parameters

    • Optional options: CreateBatchOptions

      Configures the behavior of the batch.

      • maxSizeInBytes: The upper limit for the size of batch. The tryAdd function will return false after this limit is reached.

    Returns Promise<ServiceBusMessageBatch>

open

  • Opens the AMQP link to Azure Service Bus from the sender.

    It is not necessary to call this method in order to use the sender. It is recommended to call this before your first sendMessages() call if you want to front load the work of setting up the AMQP link to the service.

    Parameters

    Returns Promise<void>

scheduleMessages

  • Schedules given messages to appear on Service Bus Queue/Subscription at a later time.

    throws

    Error if the underlying connection, client or sender is closed.

    throws

    MessagingError if the service returns an error while scheduling messages.

    Parameters

    • scheduledEnqueueTimeUtc: Date

      The UTC time at which the messages should be enqueued.

    • messages: ServiceBusMessage | ServiceBusMessage[]

      Message or an array of messages that need to be scheduled.

    • Optional options: OperationOptionsBase

      Options bag to pass an abort signal or tracing options.

    Returns Promise<Long[]>

    Promise<Long[]> - The sequence numbers of messages that were scheduled. You will need the sequence number if you intend to cancel the scheduling of the messages. Save the Long type as-is in your application without converting to number. Since JavaScript only supports 53 bit numbers, converting the Long to number will cause loss in precision.

sendMessages

  • Sends the given messages after creating an AMQP Sender link if it doesn't already exist. Consider awaiting on open() beforehand to front load the work of link creation if needed.

    • To send messages to a session and/or partition enabled Queue/Topic, set the sessionId and/or partitionKey properties respectively on the messages.
    • All messages passed to the same sendMessages() call should have the same sessionId (if using sessions) and the same partitionKey (if using partitions).
    throws

    Error if the underlying connection, client or sender is closed.

    throws

    MessagingError if the service returns an error while sending messages to the service.

    Parameters

    Returns Promise<void>

    Promise

Generated using TypeDoc