Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ServiceBusSessionReceiver

Package version

A receiver that handles sessions, including renewing the session lock.

Hierarchy

Index

Properties

entityPath

entityPath: string

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

isClosed

isClosed: boolean

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

readonly

receiveMode

receiveMode: "peekLock" | "receiveAndDelete"

The receive mode used to create the receiver.

sessionId

sessionId: string

The session ID.

sessionLockedUntilUtc

sessionLockedUntilUtc: Date

The time in UTC until which the session is locked. Every time renewSessionLock() is called, this time gets updated to current time plus the lock duration as specified during the Queue/Subscription creation.

Will return undefined until a AMQP receiver link has been successfully set up for the session.

readonly

Methods

abandonMessage

  • The lock held on the message by the receiver is let go, making the message available again in Service Bus for another receive operation.

    throws

    ServiceBusError with the code SessionLockLost (for messages from a Queue/Subscription with sessions enabled) if the AMQP link with which the message was received is no longer alive. This can happen either because the lock on the session expired or the receiver was explicitly closed by the user or the AMQP link is closed by the library due to network loss or service error.

    throws

    ServiceBusError with the code MessageLockLost (for messages from a Queue/Subscription with sessions not enabled) if the lock on the message has expired or the AMQP link with which the message was received is no longer alive. The latter can happen if the receiver was explicitly closed by the user or the AMQP link got closed by the library due to network loss or service error.

    throws

    Error if the message is already settled. property on the message if you are not sure whether the message is settled.

    throws

    Error if used in receiveAndDelete mode because all messages received in this mode are pre-settled. To avoid this error, update your code to not settle a message which is received in this mode.

    throws

    ServiceBusError with the code ServiceTimeout if Service Bus does not acknowledge the request to settle the message in time. The message may or may not have been settled successfully.

    Parameters

    • message: ServiceBusReceivedMessage
    • Optional propertiesToModify: undefined | {}

      The properties of the message to modify while abandoning the message.

    Returns Promise<void>

close

  • close(): Promise<void>

completeMessage

  • Removes the message from Service Bus.

    throws

    Error with name SessionLockLostError (for messages from a Queue/Subscription with sessions enabled) if the AMQP link with which the message was received is no longer alive. This can happen either because the lock on the session expired or the receiver was explicitly closed by the user or the AMQP link is closed by the library due to network loss or service error.

    throws

    Error with name MessageLockLostError (for messages from a Queue/Subscription with sessions not enabled) if the lock on the message has expired or the AMQP link with which the message was received is no longer alive. The latter can happen if the receiver was explicitly closed by the user or the AMQP link got closed by the library due to network loss or service error.

    throws

    Error if the message is already settled. property on the message if you are not sure whether the message is settled.

    throws

    Error if used in receiveAndDelete mode because all messages received in this mode are pre-settled. To avoid this error, update your code to not settle a message which is received in this mode.

    throws

    Error with name ServiceUnavailableError if Service Bus does not acknowledge the request to settle the message in time. The message may or may not have been settled successfully.

    Parameters

    Returns Promise<void>

deadLetterMessage

  • Moves the message to the deadletter sub-queue. To receive a deadletted message, create a new QueueClient/SubscriptionClient using the path for the deadletter sub-queue.

    throws

    ServiceBusError with the code SessionLockLost (for messages from a Queue/Subscription with sessions enabled) if the AMQP link with which the message was received is no longer alive. This can happen either because the lock on the session expired or the receiver was explicitly closed by the user or the AMQP link is closed by the library due to network loss or service error.

    throws

    ServiceBusError with the code MessageLockLost (for messages from a Queue/Subscription with sessions not enabled) if the lock on the message has expired or the AMQP link with which the message was received is no longer alive. The latter can happen if the receiver was explicitly closed by the user or the AMQP link got closed by the library due to network loss or service error.

    throws

    Error if the message is already settled. property on the message if you are not sure whether the message is settled.

    throws

    Error if used in receiveAndDelete mode because all messages received in this mode are pre-settled. To avoid this error, update your code to not settle a message which is received in this mode.

    throws

    ServiceBusError with the code ServiceTimeout if Service Bus does not acknowledge the request to settle the message in time. The message may or may not have been settled successfully.

    Parameters

    Returns Promise<void>

deferMessage

  • Defers the processing of the message. Save the sequenceNumber of the message, in order to receive it message again in the future using the receiveDeferredMessage method.

    throws

    ServiceBusError with the code SessionLockLost (for messages from a Queue/Subscription with sessions enabled) if the AMQP link with which the message was received is no longer alive. This can happen either because the lock on the session expired or the receiver was explicitly closed by the user or the AMQP link is closed by the library due to network loss or service error.

    throws

    ServiceBusError with the code MessageLockLost (for messages from a Queue/Subscription with sessions not enabled) if the lock on the message has expired or the AMQP link with which the message was received is no longer alive. The latter can happen if the receiver was explicitly closed by the user or the AMQP link got closed by the library due to network loss or service error.

    throws

    Error if the message is already settled. property on the message if you are not sure whether the message is settled.

    throws

    Error if used in receiveAndDelete mode because all messages received in this mode are pre-settled. To avoid this error, update your code to not settle a message which is received in this mode.

    throws

    ServiceBusError with the code ServiceTimeout if Service Bus does not acknowledge the request to settle the message in time. The message may or may not have been settled successfully.

    Parameters

    • message: ServiceBusReceivedMessage
    • Optional propertiesToModify: undefined | {}

      The properties of the message to modify while deferring the message

    Returns Promise<void>

getMessageIterator

getSessionState

peekMessages

  • Peek the next batch of active messages (including deferred but not deadlettered messages) on the queue or subscription without modifying them.

    • The first call to peekMessages() fetches the first active message. Each subsequent call fetches the subsequent message.
    • Unlike a "received" message, "peeked" message is a read-only version of the message. It cannot be Completed/Abandoned/Deferred/Deadlettered.

    Parameters

    • maxMessageCount: number

      The maximum number of messages to peek.

    • Optional options: PeekMessagesOptions

      Options that allow to specify the maximum number of messages to peek, the sequenceNumber to start peeking from or an abortSignal to abort the operation.

    Returns Promise<ServiceBusReceivedMessage[]>

receiveDeferredMessages

receiveMessages

  • Returns a promise that resolves to an array of messages received from Service Bus.

    throws

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

    throws

    Error if current receiver is already in state of receiving messages.

    throws

    ServiceBusError if the service returns an error while receiving messages.

    Parameters

    • maxMessageCount: number

      The maximum number of messages to receive.

    • Optional options: ReceiveMessagesOptions

      A set of options to control the receive operation.

      • maxWaitTimeInMs: The maximum time to wait for the first message before returning an empty array if no messages are available.
      • abortSignal: The signal to use to abort the ongoing operation.

    Returns Promise<ServiceBusReceivedMessage[]>

    A promise that resolves with an array of messages.

renewMessageLock

  • Renews the lock on the message for the duration as specified during the Queue/Subscription creation.

    • Check the lockedUntilUtc property on the message for the time when the lock expires.
    • If a message is not settled (using either complete(), defer() or deadletter(), before its lock expires, then the message lands back in the Queue/Subscription for the next receive operation.
    throws

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

    throws

    ServiceBusError if the service returns an error while renewing message lock.

    Parameters

    Returns Promise<Date>

    New lock token expiry date and time in UTC format.

renewSessionLock

setSessionState

subscribe

Generated using TypeDoc