Options
All
  • Public
  • Public/Protected
  • All
Menu

Class QueueClient

Package version

A QueueClient represents a URL to an Azure Storage Queue's messages allowing you to manipulate its messages.

Hierarchy

Index

Constructors

constructor

Properties

accountName

accountName: string

Protected credential

credential: Credential

Credential factory in the pipleline to authenticate requests to the service, such as AnonymousCredential, StorageSharedKeyCredential. Initialized to an AnonymousCredential if not able to retrieve it from the pipeline.

internal

Protected pipeline

pipeline: Pipeline

Request policy pipeline.

internal

Protected storageClientContext

storageClientContext: StorageClientContext

StorageClientContext is a reference to protocol layer operations entry, which is generated by AutoRest generator.

url

url: string

URL string value.

Accessors

name

  • get name(): string

Methods

clearMessages

create

createIfNotExists

delete

deleteIfExists

deleteMessage

exists

  • Returns true if the specified queue exists; false otherwise.

    NOTE: use this function with care since an existing queue might be deleted by other clients or applications. Vice versa new queues might be added by other clients or applications after this function completes.

    Parameters

    Returns Promise<boolean>

generateSasUrl

getAccessPolicy

getProperties

peekMessages

receiveMessages

  • receiveMessages retrieves one or more messages from the front of the queue.

    see

    https://docs.microsoft.com/en-us/rest/api/storageservices/get-messages

    Parameters

    Returns Promise<QueueReceiveMessageResponse>

    Response data for the receive messages operation.

    Example usage:

    const response = await queueClient.receiveMessages();
    if (response.receivedMessageItems.length == 1) {
      const receivedMessageItem = response.receivedMessageItems[0];
      console.log("Processing & deleting message with content:", receivedMessageItem.messageText);
      const deleteMessageResponse = await queueClient.deleteMessage(
        receivedMessageItem.messageId,
        receivedMessageItem.popReceipt
      );
      console.log(
        "Delete message successfully, service assigned request Id:",
        deleteMessageResponse.requestId
      );
    }

sendMessage

  • sendMessage adds a new message to the back of a queue. The visibility timeout specifies how long the message should be invisible to Dequeue and Peek operations. The message content is up to 64KB in size, and must be in a format that can be included in an XML request with UTF-8 encoding. To include markup in the message, the contents of the message must either be XML-escaped or Base64-encode.

    see

    https://docs.microsoft.com/en-us/rest/api/storageservices/put-message

    Parameters

    • messageText: string

      Text of the message to send

    • Default value options: QueueSendMessageOptions = {}

      Options to send messages operation.

    Returns Promise<QueueSendMessageResponse>

    Response data for the send messages operation.

    Example usage:

    const sendMessageResponse = await queueClient.sendMessage("Hello World!");
    console.log(
      "Sent message successfully, service assigned message Id:", sendMessageResponse.messageId,
      "service assigned request Id:", sendMessageResponse.requestId
    );

setAccessPolicy

setMetadata

updateMessage

  • Update changes a message's visibility timeout and contents. The message content is up to 64KB in size, and must be in a format that can be included in an XML request with UTF-8 encoding. To include markup in the message, the contents of the message must either be XML-escaped or Base64-encode.

    see

    https://docs.microsoft.com/en-us/rest/api/storageservices/update-message

    Parameters

    • messageId: string

      Id of the message

    • popReceipt: string

      A valid pop receipt value returned from an earlier call to the receive messages or update message operation.

    • Optional message: undefined | string

      Message to update. If this parameter is undefined, then the content of the message won't be updated.

    • Optional visibilityTimeout: undefined | number

      Specifies the new visibility timeout value, in seconds, relative to server time. The new value must be larger than or equal to 0, and cannot be larger than 7 days. The visibility timeout of a message cannot be set to a value later than the expiry time. A message can be updated until it has been deleted or has expired.

    • Default value options: QueueUpdateMessageOptions = {}

      Options to update message operation.

    Returns Promise<QueueUpdateMessageResponse>

    Response data for the update message operation.

Generated using TypeDoc