QueueService Class

This is the main class managing queue resources.

The Queue service stores messages. A queue can contain an unlimited number of messages, each of which can be up to 64KB in size. Messages are generally added to the end of the queue and retrieved from the front of the queue, although first in, first out (FIFO) behavior is not guaranteed.

:type ~azure.storage.common.TokenCredential

Inheritance
QueueService

Constructor

QueueService(account_name=None, account_key=None, sas_token=None, is_emulated=False, protocol='https', endpoint_suffix='core.windows.net', request_session=None, connection_string=None, socket_timeout=None, token_credential=None)

Parameters

Name Description
account_name
str

The storage account name. This is used to authenticate requests signed with an account key and to construct the storage endpoint. It is required unless a connection string is given.

Default value: None
account_key
str

The storage account key. This is used for shared key authentication.

Default value: None
sas_token
str

A shared access signature token to use to authenticate requests instead of the account key. If account key and sas token are both specified, account key will be used to sign.

Default value: None
is_emulated

Whether to use the emulator. Defaults to False. If specified, will override all other parameters besides connection string and request session.

Default value: False
protocol
str

The protocol to use for requests. Defaults to https.

Default value: https
endpoint_suffix
str

The host base component of the url, minus the account name. Defaults to Azure (core.windows.net). Override this to use the China cloud (core.chinacloudapi.cn).

Default value: core.windows.net
request_session
<xref:requests.Session>

The session object to use for http requests.

Default value: None
connection_string
str

If specified, this will override all other parameters besides request session. See http://azure.microsoft.com/en-us/documentation/articles/storage-configure-connection-string/ for the connection string format.

Default value: None
socket_timeout
int

If specified, this will override the default socket timeout. The timeout specified is in seconds. See DEFAULT_SOCKET_TIMEOUT in _constants.py for the default value.

Default value: None
token_credential

A token credential used to authenticate HTTPS requests. The token value should be updated before its expiration.

Default value: None

Variables

Name Description
encode_function
<xref:function>(<xref:data>)

A function used to encode queue messages. Takes as a parameter the data passed to the put_message API and returns the encoded message. Defaults to take text and xml encode, but bytes and other encodings can be used. For example, base64 may be preferable for developing across multiple Azure Storage libraries in different languages. See the QueueMessageFormat for xml, base64 and no encoding methods as well as binary equivalents.

decode_function
<xref:function>(<xref:data>)

A function used to encode decode messages. Takes as a parameter the data returned by the get_messages and peek_messages APIs and returns the decoded message. Defaults to return text and xml decode, but bytes and other decodings can be used. For example, base64 may be preferable for developing across multiple Azure Storage libraries in different languages. See the QueueMessageFormat for xml, base64 and no decoding methods as well as binary equivalents.

key_encryption_key

The key-encryption-key optionally provided by the user. If provided, will be used to encrypt/decrypt in supported methods. For methods requiring decryption, either the key_encryption_key OR the resolver must be provided. If both are provided, the resolver will take precedence. Must implement the following methods for APIs requiring encryption: wrap_key(key)–wraps the specified key (bytes) using an algorithm of the user's choice. Returns the encrypted key as bytes. get_key_wrap_algorithm()–returns the algorithm used to wrap the specified symmetric key. get_kid()–returns a string key id for this key-encryption-key. Must implement the following methods for APIs requiring decryption: unwrap_key(key, algorithm)–returns the unwrapped form of the specified symmetric key using the string-specified algorithm. get_kid()–returns a string key id for this key-encryption-key.

key_resolver_function
kid) (<xref:function>

A function to resolve keys optionally provided by the user. If provided, will be used to decrypt in supported methods. For methods requiring decryption, either the key_encryption_key OR the resolver must be provided. If both are provided, the resolver will take precedence. It uses the kid string to return a key-encryption-key implementing the interface defined above.

require_encryption

A flag that may be set to ensure that all messages successfully uploaded to the queue and all those downloaded and successfully read from the queue are/were encrypted while on the server. If this flag is set, all required parameters for encryption/decryption must be provided. See the above comments on the key_encryption_key and resolver.

Methods

clear_messages

Deletes all messages from the specified queue.

create_queue

Creates a queue under the given account.

delete_message

Deletes the specified message.

Normally after a client retrieves a message with the get_messages operation, the client is expected to process and delete the message. To delete the message, you must have two items of data: id and pop_receipt. The id is returned from the previous get_messages operation. The pop_receipt is returned from the most recent get_messages or update_message operation. In order for the delete_message operation to succeed, the pop_receipt specified on the request must match the pop_receipt returned from the get_messages or update_message operation.

delete_queue

Deletes the specified queue and any messages it contains.

When a queue is successfully deleted, it is immediately marked for deletion and is no longer accessible to clients. The queue is later removed from the Queue service during garbage collection.

Note that deleting a queue is likely to take at least 40 seconds to complete. If an operation is attempted against the queue while it was being deleted, an <xref:azure.storage.queue.queueservice.AzureConflictHttpError> will be thrown.

exists

Returns a boolean indicating whether the queue exists.

extract_date_and_request_id
generate_account_shared_access_signature

Generates a shared access signature for the queue service. Use the returned signature with the sas_token parameter of QueueService.

generate_queue_shared_access_signature

Generates a shared access signature for the queue. Use the returned signature with the sas_token parameter of QueueService.

get_messages

Retrieves one or more messages from the front of the queue.

When a message is retrieved from the queue, the response includes the message content and a pop_receipt value, which is required to delete the message. The message is not automatically deleted from the queue, but after it has been retrieved, it is not visible to other clients for the time interval specified by the visibility_timeout parameter.

If the key-encryption-key or resolver field is set on the local service object, the messages will be decrypted before being returned.

get_queue_acl

Returns details about any stored access policies specified on the queue that may be used with Shared Access Signatures.

get_queue_metadata

Retrieves user-defined metadata and queue properties on the specified queue. Metadata is associated with the queue as name-value pairs.

get_queue_service_properties

Gets the properties of a storage account's Queue service, including logging, analytics and CORS rules.

get_queue_service_stats

Retrieves statistics related to replication for the Queue service. It is only available when read-access geo-redundant replication is enabled for the storage account.

With geo-redundant replication, Azure Storage maintains your data durable in two locations. In both locations, Azure Storage constantly maintains multiple healthy replicas of your data. The location where you read, create, update, or delete data is the primary storage account location. The primary location exists in the region you choose at the time you create an account via the Azure Management Azure classic portal, for example, North Central US. The location to which your data is replicated is the secondary location. The secondary location is automatically determined based on the location of the primary; it is in a second data center that resides in the same region as the primary location. Read-only access is available from the secondary location, if read-access geo-redundant replication is enabled for your storage account.

list_queues

Returns a generator to list the queues. The generator will lazily follow the continuation tokens returned by the service and stop when all queues have been returned or num_results is reached.

If num_results is specified and the account has more than that number of queues, the generator will have a populated next_marker field once it finishes. This marker can be used to create a new generator if more results are desired.

peek_messages

Retrieves one or more messages from the front of the queue, but does not alter the visibility of the message.

Only messages that are visible may be retrieved. When a message is retrieved for the first time with a call to get_messages, its dequeue_count property is set to 1. If it is not deleted and is subsequently retrieved again, the dequeue_count property is incremented. The client may use this value to determine how many times a message has been retrieved. Note that a call to peek_messages does not increment the value of DequeueCount, but returns this value for the client to read.

If the key-encryption-key or resolver field is set on the local service object, the messages will be decrypted before being returned.

put_message

Adds a new message to the back of the message queue.

The visibility timeout specifies the time that the message will be invisible. After the timeout expires, the message will become visible. If a visibility timeout is not specified, the default value of 0 is used.

The message time-to-live specifies how long a message will remain in the queue. The message will be deleted from the queue when the time-to-live period expires.

If the key-encryption-key field is set on the local service object, this method will encrypt the content before uploading.

set_proxy

Sets the proxy server host and port for the HTTP CONNECT Tunnelling.

set_queue_acl

Sets stored access policies for the queue that may be used with Shared Access Signatures.

When you set permissions for a queue, the existing permissions are replaced. To update the queue's permissions, call get_queue_acl to fetch all access policies associated with the queue, modify the access policy that you wish to change, and then call this function with the complete set of data to perform the update.

When you establish a stored access policy on a queue, it may take up to 30 seconds to take effect. During this interval, a shared access signature that is associated with the stored access policy will throw an <xref:azure.storage.queue.queueservice.AzureHttpError> until the access policy becomes active.

set_queue_metadata

Sets user-defined metadata on the specified queue. Metadata is associated with the queue as name-value pairs.

set_queue_service_properties

Sets the properties of a storage account's Queue service, including Azure Storage Analytics. If an element (ex Logging) is left as None, the existing settings on the service for that functionality are preserved. For more information on Azure Storage Analytics, see https://msdn.microsoft.com/en-us/library/azure/hh343270.aspx.

update_message

Updates the visibility timeout of a message. You can also use this operation to update the contents of a message.

This operation can be used to continually extend the invisibility of a queue message. This functionality can be useful if you want a worker role to "lease" a queue message. For example, if a worker role calls get_messages and recognizes that it needs more time to process a message, it can continually extend the message's invisibility until it is processed. If the worker role were to fail during processing, eventually the message would become visible again and another worker role could process it.

If the key-encryption-key field is set on the local service object, this method will encrypt the content before uploading.

clear_messages

Deletes all messages from the specified queue.

clear_messages(queue_name, timeout=None)

Parameters

Name Description
queue_name
Required
str

The name of the queue whose messages to clear.

timeout
int

The server timeout, expressed in seconds.

Default value: None

create_queue

Creates a queue under the given account.

create_queue(queue_name, metadata=None, fail_on_exist=False, timeout=None)

Parameters

Name Description
queue_name
Required
str

The name of the queue to create. A queue name must be from 3 through 63 characters long and may only contain lowercase letters, numbers, and the dash (-) character. The first and last letters in the queue must be alphanumeric. The dash (-) character cannot be the first or last character. Consecutive dash characters are not permitted in the queue name.

metadata

A dict containing name-value pairs to associate with the queue as metadata. Note that metadata names preserve the case with which they were created, but are case-insensitive when set or read.

Default value: None
fail_on_exist

Specifies whether to throw an exception if the queue already exists.

Default value: False
timeout
int

The server timeout, expressed in seconds.

Default value: None

Returns

Type Description

A boolean indicating whether the queue was created. If fail_on_exist was set to True, this will throw instead of returning false.

delete_message

Deletes the specified message.

Normally after a client retrieves a message with the get_messages operation, the client is expected to process and delete the message. To delete the message, you must have two items of data: id and pop_receipt. The id is returned from the previous get_messages operation. The pop_receipt is returned from the most recent get_messages or update_message operation. In order for the delete_message operation to succeed, the pop_receipt specified on the request must match the pop_receipt returned from the get_messages or update_message operation.

delete_message(queue_name, message_id, pop_receipt, timeout=None)

Parameters

Name Description
queue_name
Required
str

The name of the queue from which to delete the message.

message_id
Required
str

The message id identifying the message to delete.

pop_receipt
Required
str

A valid pop receipt value returned from an earlier call to the get_messages or update_message.

timeout
int

The server timeout, expressed in seconds.

Default value: None

delete_queue

Deletes the specified queue and any messages it contains.

When a queue is successfully deleted, it is immediately marked for deletion and is no longer accessible to clients. The queue is later removed from the Queue service during garbage collection.

Note that deleting a queue is likely to take at least 40 seconds to complete. If an operation is attempted against the queue while it was being deleted, an <xref:azure.storage.queue.queueservice.AzureConflictHttpError> will be thrown.

delete_queue(queue_name, fail_not_exist=False, timeout=None)

Parameters

Name Description
queue_name
Required
str

The name of the queue to delete.

fail_not_exist

Specifies whether to throw an exception if the queue doesn't exist.

Default value: False
timeout
int

The server timeout, expressed in seconds.

Default value: None

Returns

Type Description

A boolean indicating whether the queue was deleted. If fail_not_exist was set to True, this will throw instead of returning false.

exists

Returns a boolean indicating whether the queue exists.

exists(queue_name, timeout=None)

Parameters

Name Description
queue_name
Required
str

The name of queue to check for existence.

timeout
int

The server timeout, expressed in seconds.

Default value: None

Returns

Type Description

A boolean indicating whether the queue exists.

extract_date_and_request_id

static extract_date_and_request_id(retry_context)

Parameters

Name Description
retry_context
Required

generate_account_shared_access_signature

Generates a shared access signature for the queue service. Use the returned signature with the sas_token parameter of QueueService.

generate_account_shared_access_signature(resource_types, permission, expiry, start=None, ip=None, protocol=None)

Parameters

Name Description
resource_types
Required
<xref:ResourceTypes>

Specifies the resource types that are accessible with the account SAS.

permission
Required
<xref:AccountPermissions>

The permissions associated with the shared access signature. The user is restricted to operations allowed by the permissions. Required unless an id is given referencing a stored access policy which contains this field. This field must be omitted if it has been specified in an associated stored access policy.

expiry
Required

The time at which the shared access signature becomes invalid. Required unless an id is given referencing a stored access policy which contains this field. This field must be omitted if it has been specified in an associated stored access policy. Azure will always convert values to UTC. If a date is passed in without timezone info, it is assumed to be UTC.

start

The time at which the shared access signature becomes valid. If omitted, start time for this call is assumed to be the time when the storage service receives the request. Azure will always convert values to UTC. If a date is passed in without timezone info, it is assumed to be UTC.

Default value: None
ip
str

Specifies an IP address or a range of IP addresses from which to accept requests. If the IP address from which the request originates does not match the IP address or address range specified on the SAS token, the request is not authenticated. For example, specifying sip=168.1.5.65 or sip=168.1.5.60-168.1.5.70 on the SAS restricts the request to those IP addresses.

Default value: None
protocol
str

Specifies the protocol permitted for a request made. The default value is https,http. See Protocol for possible values.

Default value: None

Returns

Type Description
str

A Shared Access Signature (sas) token.

generate_queue_shared_access_signature

Generates a shared access signature for the queue. Use the returned signature with the sas_token parameter of QueueService.

generate_queue_shared_access_signature(queue_name, permission=None, expiry=None, start=None, id=None, ip=None, protocol=None)

Parameters

Name Description
queue_name
Required
str

The name of the queue to create a SAS token for.

permission

The permissions associated with the shared access signature. The user is restricted to operations allowed by the permissions. Required unless an id is given referencing a stored access policy which contains this field. This field must be omitted if it has been specified in an associated stored access policy.

Default value: None
expiry

The time at which the shared access signature becomes invalid. Required unless an id is given referencing a stored access policy which contains this field. This field must be omitted if it has been specified in an associated stored access policy. Azure will always convert values to UTC. If a date is passed in without timezone info, it is assumed to be UTC.

Default value: None
start

The time at which the shared access signature becomes valid. If omitted, start time for this call is assumed to be the time when the storage service receives the request. Azure will always convert values to UTC. If a date is passed in without timezone info, it is assumed to be UTC.

Default value: None
id
str

A unique value up to 64 characters in length that correlates to a stored access policy. To create a stored access policy, use set_queue_acl.

Default value: None
ip
str

Specifies an IP address or a range of IP addresses from which to accept requests. If the IP address from which the request originates does not match the IP address or address range specified on the SAS token, the request is not authenticated. For example, specifying sip='168.1.5.65' or sip='168.1.5.60-168.1.5.70' on the SAS restricts the request to those IP addresses.

Default value: None
protocol
str

Specifies the protocol permitted for a request made. The default value is https,http. See Protocol for possible values.

Default value: None

Returns

Type Description
str

A Shared Access Signature (sas) token.

get_messages

Retrieves one or more messages from the front of the queue.

When a message is retrieved from the queue, the response includes the message content and a pop_receipt value, which is required to delete the message. The message is not automatically deleted from the queue, but after it has been retrieved, it is not visible to other clients for the time interval specified by the visibility_timeout parameter.

If the key-encryption-key or resolver field is set on the local service object, the messages will be decrypted before being returned.

get_messages(queue_name, num_messages=None, visibility_timeout=None, timeout=None)

Parameters

Name Description
queue_name
Required
str

The name of the queue to get messages from.

num_messages
int

A nonzero integer value that specifies the number of messages to retrieve from the queue, up to a maximum of 32. If fewer are visible, the visible messages are returned. By default, a single message is retrieved from the queue with this operation.

Default value: None
visibility_timeout
int

Specifies the new visibility timeout value, in seconds, relative to server time. The new value must be larger than or equal to 1 second, and cannot be larger than 7 days. The visibility timeout of a message can be set to a value later than the expiry time.

Default value: None
timeout
int

The server timeout, expressed in seconds.

Default value: None

Returns

Type Description

A QueueMessage object representing the information passed.

get_queue_acl

Returns details about any stored access policies specified on the queue that may be used with Shared Access Signatures.

get_queue_acl(queue_name, timeout=None)

Parameters

Name Description
queue_name
Required
str

The name of an existing queue.

timeout
int

The server timeout, expressed in seconds.

Default value: None

Returns

Type Description

A dictionary of access policies associated with the queue.

get_queue_metadata

Retrieves user-defined metadata and queue properties on the specified queue. Metadata is associated with the queue as name-value pairs.

get_queue_metadata(queue_name, timeout=None)

Parameters

Name Description
queue_name
Required
str

The name of an existing queue.

timeout
int

The server timeout, expressed in seconds.

Default value: None

Returns

Type Description

A dictionary representing the queue metadata with an approximate_message_count int property on the dict estimating the number of messages in the queue.

get_queue_service_properties

Gets the properties of a storage account's Queue service, including logging, analytics and CORS rules.

get_queue_service_properties(timeout=None)

Parameters

Name Description
timeout
int

The server timeout, expressed in seconds.

Default value: None

Returns

Type Description

The queue service properties.

get_queue_service_stats

Retrieves statistics related to replication for the Queue service. It is only available when read-access geo-redundant replication is enabled for the storage account.

With geo-redundant replication, Azure Storage maintains your data durable in two locations. In both locations, Azure Storage constantly maintains multiple healthy replicas of your data. The location where you read, create, update, or delete data is the primary storage account location. The primary location exists in the region you choose at the time you create an account via the Azure Management Azure classic portal, for example, North Central US. The location to which your data is replicated is the secondary location. The secondary location is automatically determined based on the location of the primary; it is in a second data center that resides in the same region as the primary location. Read-only access is available from the secondary location, if read-access geo-redundant replication is enabled for your storage account.

get_queue_service_stats(timeout=None)

Parameters

Name Description
timeout
int

The timeout parameter is expressed in seconds.

Default value: None

Returns

Type Description

The queue service stats.

list_queues

Returns a generator to list the queues. The generator will lazily follow the continuation tokens returned by the service and stop when all queues have been returned or num_results is reached.

If num_results is specified and the account has more than that number of queues, the generator will have a populated next_marker field once it finishes. This marker can be used to create a new generator if more results are desired.

list_queues(prefix=None, num_results=None, include_metadata=False, marker=None, timeout=None)

Parameters

Name Description
prefix
str

Filters the results to return only queues with names that begin with the specified prefix.

Default value: None
num_results
int

The maximum number of queues to return.

Default value: None
include_metadata

Specifies that container metadata be returned in the response.

Default value: False
marker
str

An opaque continuation token. This value can be retrieved from the next_marker field of a previous generator object if num_results was specified and that generator has finished enumerating results. If specified, this generator will begin returning results from the point where the previous generator stopped.

Default value: None
timeout
int

The server timeout, expressed in seconds. This function may make multiple calls to the service in which case the timeout value specified will be applied to each individual call.

Default value: None

peek_messages

Retrieves one or more messages from the front of the queue, but does not alter the visibility of the message.

Only messages that are visible may be retrieved. When a message is retrieved for the first time with a call to get_messages, its dequeue_count property is set to 1. If it is not deleted and is subsequently retrieved again, the dequeue_count property is incremented. The client may use this value to determine how many times a message has been retrieved. Note that a call to peek_messages does not increment the value of DequeueCount, but returns this value for the client to read.

If the key-encryption-key or resolver field is set on the local service object, the messages will be decrypted before being returned.

peek_messages(queue_name, num_messages=None, timeout=None)

Parameters

Name Description
queue_name
Required
str

The name of the queue to peek messages from.

num_messages
int

A nonzero integer value that specifies the number of messages to peek from the queue, up to a maximum of 32. By default, a single message is peeked from the queue with this operation.

Default value: None
timeout
int

The server timeout, expressed in seconds.

Default value: None

Returns

Type Description

A list of QueueMessage objects. Note that time_next_visible and pop_receipt will not be populated as peek does not pop the message and can only retrieve already visible messages.

put_message

Adds a new message to the back of the message queue.

The visibility timeout specifies the time that the message will be invisible. After the timeout expires, the message will become visible. If a visibility timeout is not specified, the default value of 0 is used.

The message time-to-live specifies how long a message will remain in the queue. The message will be deleted from the queue when the time-to-live period expires.

If the key-encryption-key field is set on the local service object, this method will encrypt the content before uploading.

put_message(queue_name, content, visibility_timeout=None, time_to_live=None, timeout=None)

Parameters

Name Description
queue_name
Required
str

The name of the queue to put the message into.

content
Required
<xref:obj>

Message content. Allowed type is determined by the encode_function set on the service. Default is str. The encoded message can be up to 64KB in size.

visibility_timeout
int

If not specified, the default value is 0. Specifies the new visibility timeout value, in seconds, relative to server time. The 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. visibility_timeout should be set to a value smaller than the time-to-live value.

Default value: None
time_to_live
int

Specifies the time-to-live interval for the message, in seconds. The time-to-live may be any positive number or -1 for infinity. If this parameter is omitted, the default time-to-live is 7 days.

Default value: None
timeout
int

The server timeout, expressed in seconds.

Default value: None

Returns

Type Description

A QueueMessage object. This object is also populated with the content although it is not returned from the service.

set_proxy

Sets the proxy server host and port for the HTTP CONNECT Tunnelling.

set_proxy(host, port, user=None, password=None)

Parameters

Name Description
host
Required
str

Address of the proxy. Ex: '192.168.0.100'

port
Required
int

Port of the proxy. Ex: 6000

user
str

User for proxy authorization.

Default value: None
password
str

Password for proxy authorization.

Default value: None

set_queue_acl

Sets stored access policies for the queue that may be used with Shared Access Signatures.

When you set permissions for a queue, the existing permissions are replaced. To update the queue's permissions, call get_queue_acl to fetch all access policies associated with the queue, modify the access policy that you wish to change, and then call this function with the complete set of data to perform the update.

When you establish a stored access policy on a queue, it may take up to 30 seconds to take effect. During this interval, a shared access signature that is associated with the stored access policy will throw an <xref:azure.storage.queue.queueservice.AzureHttpError> until the access policy becomes active.

set_queue_acl(queue_name, signed_identifiers=None, timeout=None)

Parameters

Name Description
queue_name
Required
str

The name of an existing queue.

signed_identifiers
dict(str, AccessPolicy)

A dictionary of access policies to associate with the queue. The dictionary may contain up to 5 elements. An empty dictionary will clear the access policies set on the service.

Default value: None
timeout
int

The server timeout, expressed in seconds.

Default value: None

set_queue_metadata

Sets user-defined metadata on the specified queue. Metadata is associated with the queue as name-value pairs.

set_queue_metadata(queue_name, metadata=None, timeout=None)

Parameters

Name Description
queue_name
Required
str

The name of an existing queue.

metadata

A dict containing name-value pairs to associate with the queue as metadata.

Default value: None
timeout
int

The server timeout, expressed in seconds.

Default value: None

set_queue_service_properties

Sets the properties of a storage account's Queue service, including Azure Storage Analytics. If an element (ex Logging) is left as None, the existing settings on the service for that functionality are preserved. For more information on Azure Storage Analytics, see https://msdn.microsoft.com/en-us/library/azure/hh343270.aspx.

set_queue_service_properties(logging=None, hour_metrics=None, minute_metrics=None, cors=None, timeout=None)

Parameters

Name Description
logging
<xref:Logging>

The logging settings provide request logs.

Default value: None
hour_metrics
<xref:Metrics>

The hour metrics settings provide a summary of request statistics grouped by API in hourly aggregates for queuess.

Default value: None
minute_metrics
<xref:Metrics>

The minute metrics settings provide request statistics for each minute for queues.

Default value: None
cors
list(CorsRule)

You can include up to five CorsRule elements in the list. If an empty list is specified, all CORS rules will be deleted, and CORS will be disabled for the service. For detailed information about CORS rules and evaluation logic, see https://msdn.microsoft.com/en-us/library/azure/dn535601.aspx.

Default value: None
timeout
int

The server timeout, expressed in seconds.

Default value: None

update_message

Updates the visibility timeout of a message. You can also use this operation to update the contents of a message.

This operation can be used to continually extend the invisibility of a queue message. This functionality can be useful if you want a worker role to "lease" a queue message. For example, if a worker role calls get_messages and recognizes that it needs more time to process a message, it can continually extend the message's invisibility until it is processed. If the worker role were to fail during processing, eventually the message would become visible again and another worker role could process it.

If the key-encryption-key field is set on the local service object, this method will encrypt the content before uploading.

update_message(queue_name, message_id, pop_receipt, visibility_timeout, content=None, timeout=None)

Parameters

Name Description
queue_name
Required
str

The name of the queue containing the message to update.

message_id
Required
str

The message id identifying the message to update.

pop_receipt
Required
str

A valid pop receipt value returned from an earlier call to the get_messages or update_message operation.

visibility_timeout
Required
int

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.

content
<xref:obj>

Message content. Allowed type is determined by the encode_function set on the service. Default is str.

Default value: None
timeout
int

The server timeout, expressed in seconds.

Default value: None

Returns

Type Description

A list of QueueMessage objects. For convenience, this object is also populated with the content, although it is not returned by the service.

Attributes

protocol

request_session

socket_timeout