Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MessageSession

Package version

internal

Describes the receiver for a Message Session.

Hierarchy

Index

Constructors

constructor

Properties

Protected _context

property

{ClientEntityContext} _context Provides relevant information about the amqp connection, cbs and $management sessions, token provider, sender and receivers.

Protected Optional _tokenRenewalTimer

_tokenRenewalTimer: NodeJS.Timer
property

{NodeJS.Timer} _tokenRenewalTimer The token renewal timer that keeps track of when the Client Entity is due for token renewal.

Protected Optional _tokenTimeout

_tokenTimeout: undefined | number
property

_tokenTimeout Indicates token timeout

address

address: string
property

{string} address The client entity address in one of the following forms:

Sender

  • "<queue-name>".
  • "<topic-name>".

Receiver

  • "<queue-name>".
  • "<topic-name>".

ManagementClient -"$management".

audience

audience: string
property

{string} audience The client entity token audience in one of the following forms:

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".

autoComplete

autoComplete: boolean
property

{boolean} autoComplete Indicates whether Message.complete() should be called automatically after the message processing is complete while receiving messages with handlers. Default: false.

autoRenewLock

autoRenewLock: boolean
property

{boolean} autoRenewLock Should lock renewal happen automatically.

callee

property

{SessionCallee} callee Describes who instantied the MessageSession. Whether it was called by the SessionManager or it was called standalone.

  • Default: "standalone"

isConnecting

isConnecting: boolean = false
property

{boolean} isConnecting Indicates whether the link is in the process of connecting (establishing) itself. Default value: false.

isReceivingMessages

isReceivingMessages: boolean

Denotes if we are currently receiving messages

maxAutoRenewDurationInMs

maxAutoRenewDurationInMs: number
property

{number} maxAutoRenewDurationInMs The maximum duration within which the lock will be renewed automatically. This value should be greater than the longest message lock duration; for example, the lockDuration property on the received message.

Default: 300 * 1000 (5 minutes);

maxConcurrentCalls

maxConcurrentCalls: number = 1
property

{number} [maxConcurrentCalls] The maximum number of messages that should be processed concurrently in a session while in streaming mode. Once this limit has been reached, more messages will not be received until the user's message handler has completed processing current message.

  • Default: 1 (message in a session at a time).

Optional maxConcurrentSessions

maxConcurrentSessions: undefined | number
property

{number} [maxConcurrentSessions] The maximum number of concurrent sessions that the client should initate.

  • Default: 1.

name

name: string
property

{string} id The unique name for the entity in the format: ${name of the entity}-${guid}.

Optional newMessageWaitTimeoutInMs

newMessageWaitTimeoutInMs: undefined | number
property

{number} [newMessageWaitTimeoutInMs] The maximum amount of idle time the session receiver will wait after a message has been received. If no messages are received in that time frame then the session will be closed.

receiveMode

receiveMode: ReceiveMode
property

{number} [receiveMode] The mode in which messages should be received. Default: ReceiveMode.peekLock

Optional sessionId

sessionId: undefined | string
property

{string} [sessionId] The sessionId for the message session. Empty string is valid sessionId

Optional sessionLockedUntilUtc

sessionLockedUntilUtc: Date
property

{Date} [sessionLockedUntilUtc] Provides the duration until which the session is locked.

Accessors

receiverHelper

  • get receiverHelper(): ReceiverHelper

Methods

Protected _closeLink

  • _closeLink(link?: AwaitableSender | Receiver): Promise<void>

Protected _ensureTokenRenewal

  • _ensureTokenRenewal(): void

Protected _negotiateClaim

  • _negotiateClaim(setTokenRenewal?: undefined | false | true): Promise<void>

close

  • close(): Promise<void>

isOpen

  • isOpen(): boolean

receive

  • Registers handlers to deal with the incoming stream of messages over an AMQP receiver link from a Queue/Subscription. To stop receiving messages, call close() on the SessionReceiver or set the property newMessageWaitTimeoutInMs in the options to provide a timeout.

    Parameters

    • onMessage: OnMessage

      Handler for processing each incoming message.

    • onError: OnError

      Handler for any error that occurs while receiving or processing messages.

    • Optional options: SessionMessageHandlerOptions

      Options to control whether messages should be automatically completed. You can also provide a timeout in milliseconds to denote the amount of time to wait for a new message before closing the receiver.

    Returns void

    void

receiveMessages

  • receiveMessages(maxMessageCount: number, maxWaitTimeInMs: number): Promise<ServiceBusMessageImpl[]>
  • Returns a batch of messages based on given count and timeout over an AMQP receiver link from a Queue/Subscription.

    Parameters

    • maxMessageCount: number

      The maximum number of messages to receive from Queue/Subscription.

    • maxWaitTimeInMs: number

      The total wait time in milliseconds until which the receiver will attempt to receive specified number of messages. If this time elapses before the maxMessageCount is reached, then messages collected till then will be returned to the user.

    Returns Promise<ServiceBusMessageImpl[]>

    Promise<ServiceBusMessage[]> A promise that resolves with an array of Message objects.

settleMessage

  • settleMessage(message: ServiceBusMessageImpl, operation: DispositionType, options?: DispositionStatusOptions): Promise<any>

Static create

Generated using TypeDoc