CbsClient class

Describes the EventHub/ServiceBus Cbs client that talks to the $cbs endpoint over AMQP connection.

Constructors

CbsClient(Connection, string)

Properties

cbsLock

The unique lock name per $cbs session per connection that is used to acquire the lock for establishing a cbs session if one does not exist for an amqp connection.

connection

The AMQP connection.

connectionLock

The unique lock name per connection that is used to acquire the lock for establishing an amqp connection if one does not exist.

endpoint

CBS endpoint - "$cbs"

replyTo

CBS replyTo - The receiver link name that the service should reply to.

Methods

close()

Closes the AMQP cbs session to the EventHub/ServiceBus for this client, returning a promise that will be resolved when disconnection is completed.

init({ abortSignal?: AbortSignalLike, timeoutInMs?: number })

Creates a singleton instance of the CBS session if it hasn't been initialized previously on the given connection.

isOpen()

Indicates whether the cbs sender receiver link is open or closed.

negotiateClaim(string, string, TokenType, { abortSignal?: AbortSignalLike, timeoutInMs?: number })

Negotiates the CBS claim with the EventHub/ServiceBus Service.

remove()

Removes the AMQP cbs session to the EventHub/ServiceBus for this client,

Constructor Details

CbsClient(Connection, string)

new CbsClient(connection: Connection, connectionLock: string)

Parameters

connection

Connection

The AMQP connection.

connectionLock

string

A unique string (usually a guid) per connection.

Property Details

cbsLock

The unique lock name per $cbs session per connection that is used to acquire the lock for establishing a cbs session if one does not exist for an amqp connection.

cbsLock: string

Property Value

string

connection

The AMQP connection.

connection: Connection

Property Value

Connection

connectionLock

The unique lock name per connection that is used to acquire the lock for establishing an amqp connection if one does not exist.

connectionLock: string

Property Value

string

endpoint

CBS endpoint - "$cbs"

endpoint: string

Property Value

string

replyTo

CBS replyTo - The receiver link name that the service should reply to.

replyTo: string

Property Value

string

Method Details

close()

Closes the AMQP cbs session to the EventHub/ServiceBus for this client, returning a promise that will be resolved when disconnection is completed.

function close(): Promise<void>

Returns

Promise<void>

init({ abortSignal?: AbortSignalLike, timeoutInMs?: number })

Creates a singleton instance of the CBS session if it hasn't been initialized previously on the given connection.

function init(options?: { abortSignal?: AbortSignalLike, timeoutInMs?: number }): Promise<void>

Parameters

options

{ abortSignal?: AbortSignalLike, timeoutInMs?: number }

Optional parameters that can be used to affect this method's behavior. For example, abortSignal can be passed to allow cancelling an in-progress init invocation.

Returns

Promise<void>

Promise.

isOpen()

Indicates whether the cbs sender receiver link is open or closed.

function isOpen(): boolean

Returns

boolean

true open, false closed.

negotiateClaim(string, string, TokenType, { abortSignal?: AbortSignalLike, timeoutInMs?: number })

Negotiates the CBS claim with the EventHub/ServiceBus Service.

function negotiateClaim(audience: string, token: string, tokenType: TokenType, options?: { abortSignal?: AbortSignalLike, timeoutInMs?: number }): Promise<CbsResponse>

Parameters

audience

string

The entity token audience for which the token is requested in one of the following forms:

  • ServiceBus

    • Sender

      • "sb://<yournamespace>.servicebus.windows.net/<queue-name>"
      • "sb://<yournamespace>.servicebus.windows.net/<topic-name>"
    • Receiver - "sb://<yournamespace>.servicebus.windows.net/<queue-name>" - "sb://<yournamespace>.servicebus.windows.net/<topic-name>"

    • ManagementClient - "sb://<your-namespace>.servicebus.windows.net/<queue-name>/$management". - "sb://<your-namespace>.servicebus.windows.net/<topic-name>/$management".

  • EventHubs

    • Sender

      • "sb://<yournamespace>.servicebus.windows.net/<hubName>"
      • "sb://<yournamespace>.servicebus.windows.net/<hubName>/Partitions/<partitionId>".
    • Receiver

      • "sb://<your-namespace>.servicebus.windows.net/<event-hub-name>/ConsumerGroups/<consumer-group-name>/Partitions/<partition-id>".
    • ManagementClient

      • "sb://<your-namespace>.servicebus.windows.net/<event-hub-name>/$management".
token

string

The token that needs to be sent in the put-token request.

tokenType
TokenType

The type of token being used. For example, 'jwt' or 'servicebus.windows.net:sastoken'.

options

{ abortSignal?: AbortSignalLike, timeoutInMs?: number }

Optional parameters that can be used to affect this method's behavior. For example, abortSignal can be passed to allow cancelling an in-progress negotiateClaim invocation.

Returns

Promise<CbsResponse>

A Promise that resolves when $cbs authentication is successful and rejects when an error occurs during $cbs authentication.

remove()

Removes the AMQP cbs session to the EventHub/ServiceBus for this client,

function remove()