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 | NamedKeyCredential | SASCredential

      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. Use the AzureNamedKeyCredential from @azure/core-auth if you want to pass in a SharedAccessKeyName and SharedAccessKey without using a connection string. These fields map to the name and key field respectively in AzureNamedKeyCredential. Use the AzureSASCredential from @azure/core-auth if you want to pass in a SharedAccessSignature without using a connection string. This field maps to signature in AzureSASCredential.

    • 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

acceptNextSession

  • Creates a receiver for the next available session in a session-enabled Azure Service Bus queue.

    You can choose between two receive modes: "peekLock" (default) and "receiveAndDelete".

    • In peekLock mode, the receiver has a lock on the message for the duration specified on the queue.
    • In receiveAndDelete mode, messages are deleted from Service Bus as they are received.

    You can settle a message by calling completeMessage(), abandonMessage(), deferMessage() or deadletterMessage() methods on the receiver.

    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: ServiceBusSessionReceiverOptions

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

    Returns Promise<ServiceBusSessionReceiver>

    A receiver that can be used to receive, peek and settle messages.

  • Creates a receiver for the next available session in a session-enabled Azure Service Bus subscription.

    You can choose between two receive modes: "peekLock" (default) and "receiveAndDelete".

    • In peekLock mode, the receiver has a lock on the message for the duration specified on the queue.
    • In receiveAndDelete mode, messages are deleted from Service Bus as they are received.

    You can settle a message by calling completeMessage(), abandonMessage(), deferMessage() or deadletterMessage() methods on the receiver.

    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: ServiceBusSessionReceiverOptions

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

    Returns Promise<ServiceBusSessionReceiver>

    A receiver that can be used to receive, peek and settle messages.

acceptSession

  • Creates a receiver for a session enabled Azure Service Bus queue.

    You can choose between two receive modes: "peekLock" (default) and "receiveAndDelete".

    • In peekLock mode, the receiver has a lock on the message for the duration specified on the queue.
    • In receiveAndDelete mode, messages are deleted from Service Bus as they are received.

    You can settle a message by calling completeMessage(), abandonMessage(), deferMessage() or deadletterMessage() methods on the receiver.

    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.

    • sessionId: string

      The id of the session from which messages need to be received

    • Optional options: ServiceBusSessionReceiverOptions

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

    Returns Promise<ServiceBusSessionReceiver>

    A receiver that can be used to receive, peek and settle messages.

  • Creates a receiver for a session enabled Azure Service Bus subscription.

    You can choose between two receive modes: "peekLock" (default) and "receiveAndDelete".

    • In peekLock mode, the receiver has a lock on the message for the duration specified on the queue.
    • In receiveAndDelete mode, messages are deleted from Service Bus as they are received.

    You can settle a message by calling completeMessage(), abandonMessage(), deferMessage() or deadletterMessage() methods on the receiver.

    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.

    • sessionId: string

      The id of the session from which messages need to be received

    • Optional options: ServiceBusSessionReceiverOptions

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

    Returns Promise<ServiceBusSessionReceiver>

    A receiver that can be used to receive, peek and settle messages.

close

  • close(): Promise<void>

createReceiver

  • Creates a receiver for an Azure Service Bus queue. No connection is made to the service until one of the methods on the receiver is called.

    To target sub queues like the dead letter queue or the transfer dead letter queue, provide the subQueue in the options. To learn more about dead letter queues, see https://docs.microsoft.com/azure/service-bus-messaging/service-bus-dead-letter-queues

    You can choose between two receive modes: "peekLock" (default) and "receiveAndDelete".

    • In peekLock mode, the receiver has a lock on the message for the duration specified on the queue.
    • In receiveAndDelete mode, messages are deleted from Service Bus as they are received.

    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 completeMessage(), abandonMessage(), deferMessage() or deadletterMessage() methods on the receiver.

    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: ServiceBusReceiverOptions

      Options to pass the receiveMode, defaulted to peekLock.

    Returns ServiceBusReceiver

    A receiver that can be used to receive, peek and settle messages.

  • Creates a receiver for an Azure Service Bus subscription. No connection is made to the service until one of the methods on the receiver is called.

    To target sub queues like the dead letter queue or the transfer dead letter queue, provide the subQueue in the options. To learn more about dead letter queues, see https://docs.microsoft.com/azure/service-bus-messaging/service-bus-dead-letter-queues

    You can choose between two receive modes: "peekLock" (default) and "receiveAndDelete".

    • In peekLock mode, the receiver has a lock on the message for the duration specified on the queue.
    • In receiveAndDelete mode, messages are deleted from Service Bus as they are received.

    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 completeMessage(), abandonMessage(), deferMessage() or deadletterMessage() methods on the receiver.

    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: ServiceBusReceiverOptions

      Options to pass the receiveMode, defaulted to peekLock.

    Returns ServiceBusReceiver

    A receiver that can be used to receive, peek and settle messages.

createSender

Generated using TypeDoc