Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ServiceBusClient

Package version

A client that can create Sender instances for sending messages to queues and topics as well as Receiver instances to receive messages from queues and subscriptions.

Hierarchy

  • ServiceBusClient

Index

Constructors

constructor

  • Creates an instance of the ServiceBusClient class which can be used to create senders and receivers to the Azure Service Bus namespace provided in the connection string. No connection is made to the service until the senders/receivers created with the client are used to send/receive messages.

    Parameters

    • connectionString: string

      A connection string for Azure Service Bus namespace. NOTE: this connection string can contain an EntityPath, which is ignored.

    • Optional options: ServiceBusClientOptions

      Options for the service bus client.

    Returns ServiceBusClient

  • Creates an instance of the ServiceBusClient class which can be used to create senders and receivers to the Azure Service Bus namespace provided. No connection is made to the service until the senders/receivers created with the client are used to send/receive messages.

    Parameters

    • fullyQualifiedNamespace: string

      The full namespace of your Service Bus instance which is likely to be similar to .servicebus.windows.net.

    • credential: TokenCredential

      A credential object used by the client to get the token to authenticate the connection with the Azure Service Bus. See @azure/identity for creating the credentials. If you're using an own implementation of the TokenCredential interface against AAD, then set the "scopes" for service-bus to be ["https://servicebus.azure.net//user_impersonation"] to get the appropriate token.

    • Optional options: ServiceBusClientOptions

      Options for the service bus client.

    Returns ServiceBusClient

Properties

fullyQualifiedNamespace

fullyQualifiedNamespace: string

The fully qualified namespace of the Service Bus instance for which this client is created. This is likely to be similar to .servicebus.windows.net.

Methods

close

  • close(): Promise<void>

createReceiver

createSender

createSessionReceiver

  • Creates a receiver for a session enabled Azure Service Bus queue in peekLock mode. If the receiveMode is not provided in the options, it defaults to the "peekLock" mode.

    In peekLock mode, the receiver has a lock on the session for the duration specified on the queue.

    Messages that are not settled within the lock duration will be redelivered as many times as the max delivery count set on the queue, after which they get sent to a separate dead letter queue.

    You can settle a message by calling complete(), abandon(), defer() or deadletter() methods on the message.

    More information about how peekLock and message settlement works here: https://docs.microsoft.com/azure/service-bus-messaging/message-transfers-locks-settlement#peeklock

    Parameters

    • queueName: string

      The name of the queue to receive from.

    • Optional options: CreateSessionReceiverOptions<"peekLock">

      Options include receiveMode(defaulted to peekLock), options to create session receiver.

    Returns Promise<ServiceBusSessionReceiver<ServiceBusReceivedMessageWithLock>>

    A receiver that can be used to receive messages of the form ServiceBusReceivedMessageWithLock

  • Creates a receiver for a session enabled Azure Service Bus queue in receiveAndDelete mode. If the receiveMode is not provided in the options, it defaults to the "peekLock" mode.

    In receiveAndDelete mode, messages are deleted from Service Bus as they are received.

    Parameters

    • queueName: string

      The name of the queue to receive from.

    • options: CreateSessionReceiverOptions<"receiveAndDelete">

      Options include receiveMode(defaulted to receiveAndDelete), options to create session receiver.

    Returns Promise<ServiceBusSessionReceiver<ServiceBusReceivedMessage>>

    A receiver that can be used to receive messages of the form ServiceBusReceivedMessage

  • Creates a receiver for a session enabled Azure Service Bus subscription in peekLock mode. If the receiveMode is not provided in the options, it defaults to the "peekLock" mode.

    In peekLock mode, the receiver has a lock on the session for the duration specified on the subscription.

    Messages that are not settled within the lock duration will be redelivered as many times as the max delivery count set on the subscription, after which they get sent to a separate dead letter queue.

    You can settle a message by calling complete(), abandon(), defer() or deadletter() methods on the message.

    More information about how peekLock and message settlement works here: https://docs.microsoft.com/azure/service-bus-messaging/message-transfers-locks-settlement#peeklock

    Parameters

    • topicName: string

      Name of the topic for the subscription we want to receive from.

    • subscriptionName: string

      Name of the subscription (under the topic) that we want to receive from.

    • Optional options: CreateSessionReceiverOptions<"peekLock">

      Options include receiveMode(defaulted to peekLock), options to create session receiver.

    Returns Promise<ServiceBusSessionReceiver<ServiceBusReceivedMessageWithLock>>

    A receiver that can be used to receive messages of the form ServiceBusReceivedMessageWithLock

  • Creates a receiver for a session enabled Azure Service Bus subscription in receiveAndDelete mode. If the receiveMode is not provided in the options, it defaults to the "peekLock" mode.

    In receiveAndDelete mode, messages are deleted from Service Bus as they are received.

    Parameters

    • topicName: string

      Name of the topic for the subscription we want to receive from.

    • subscriptionName: string

      Name of the subscription (under the topic) that we want to receive from.

    • options: CreateSessionReceiverOptions<"receiveAndDelete">

      Options include receiveMode(defaulted to receiveAndDelete), options to create session receiver.

    Returns Promise<ServiceBusSessionReceiver<ServiceBusReceivedMessage>>

    A receiver that can be used to receive messages of the form ServiceBusReceivedMessage

Generated using TypeDoc