Options
All
  • Public
  • Public/Protected
  • All
Menu

Class QueueClient

Package version

Describes the client that allows interacting with a Service Bus Queue. Use the createQueueClient function on the ServiceBusClient object to instantiate a QueueClient

Hierarchy

  • QueueClient

Implements

Index

Properties

entityPath

entityPath: string
readonly
property

The path for the Service Bus Queue for which this client is created.

id

id: string
readonly
property

A unique identifier for this client.

Methods

close

  • close(): Promise<void>

createReceiver

  • Creates a Receiver for receiving messages from a Queue which does not have sessions enabled.

    throws

    Error if the QueueClient or the underlying connection is closed.

    throws

    Error if an open receiver already exists on the QueueClient.

    throws

    MessagingError with name InvalidOperationError if the Queue has sessions enabled (in which case, use the overload of this method which takes sessionOptions argument)

    Parameters

    • receiveMode: ReceiveMode

      An enum indicating the mode in which messages should be received. Possible values are:

      • ReceiveMode.peekLock: Once a message is received in this mode, the receiver has a lock on the message for a particular duration. If the message is not settled by this time, it lands back on Service Bus to be fetched by the next receive operation.
      • ReceiveMode.receiveAndDelete: Messages received in this mode get automatically removed from Service Bus.

    Returns Receiver

    Receiver A receiver to receive messages from a Queue which does not have sessions enabled.

  • Creates a Receiver for receiving messages from a session enabled Queue. When no sessionId is given, a random session among the available sessions is used.

    throws

    Error if the QueueClient or the underlying connection is closed.

    throws

    Error if an open receiver already exists on the QueueClient for given sessionId.

    throws

    MessagingError with name SessionCannotBeLockedError if the Queue does not have sessions enabled (in which case do not pass the sessionOptions argument) or if Service Bus is not able to get a lock on the session (in which case try again after some time)

    Parameters

    • receiveMode: ReceiveMode

      An enum indicating the mode in which messages should be received. Possible values are:

      • ReceiveMode.peekLock: Once a message is received in this mode, the receiver has a lock on the message for a particular duration. If the message is not settled by this time, it lands back on Service Bus to be fetched by the next receive operation.
      • ReceiveMode.receiveAndDelete: Messages received in this mode get automatically removed from Service Bus.
    • sessionOptions: SessionReceiverOptions

      Options to provide sessionId and duration of automatic lock renewal for the session receiver.

    Returns SessionReceiver

    SessionReceiver A receiver to receive from a session in the Queue.

createSender

  • Creates a Sender to be used for sending messages, scheduling messages to be sent at a later time and cancelling such scheduled messages.

    throws

    Error if the QueueClient or the underlying connection is closed.

    throws

    Error if an open sender already exists on the QueueClient.

    Returns Sender

peek

  • Fetches the next batch of active messages (including deferred but not deadlettered messages).

    • The first call to peek() 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. The lock on it cannot be renewed.
    throws

    Error if the QueueClient or the underlying connection is closed.

    throws

    MessagingError if the service returns an error while peeking for messages.

    Parameters

    • Optional maxMessageCount: undefined | number

    Returns Promise<ReceivedMessageInfo[]>

    Promise<ReceivedMessageInfo[]>

peekBySequenceNumber

  • peekBySequenceNumber(fromSequenceNumber: Long, maxMessageCount?: undefined | number): Promise<ReceivedMessageInfo[]>
  • Peeks the desired number of active messages (including deferred but not deadlettered messages) from the specified sequence number.

    • Unlike a received message, peeked message is a read-only version of the message. It cannot be Completed/Abandoned/Deferred/Deadlettered. The lock on it cannot be renewed.
    throws

    Error if the QueueClient or the underlying connection is closed.

    throws

    MessagingError if the service returns an error while peeking for messages.

    Parameters

    • fromSequenceNumber: Long

      The sequence number from where to read the message.

    • Optional maxMessageCount: undefined | number

    Returns Promise<ReceivedMessageInfo[]>

    Promise<ReceivedMessageInfo[]>

Static getDeadLetterQueuePath

  • getDeadLetterQueuePath(queueName: string): string
  • Returns the corresponding dead letter queue name for the queue represented by the given name. Use this in the createQueueClient function on the ServiceBusClient instance to receive messages from a dead letter queue.

    Parameters

    • queueName: string

      Name of the queue whose dead letter counterpart's name is being fetched

    Returns string

Generated using TypeDoc