CloudQueue Class
- java.
lang. Object - com.
microsoft. azure. storage. queue. CloudQueue
- com.
public class CloudQueue
This class represents a queue in the Microsoft Azure Queue service.
Constructor Summary
Constructor | Description |
---|---|
CloudQueue(final StorageUri uri) |
Creates an instance of the class using the specified queue . The queue must include a SAS token. |
CloudQueue(final StorageUri uri, final StorageCredentials credentials) |
Creates an instance of the class using the specified queue and credentials. If the contains a SAS token, the credentials must be . |
CloudQueue(final String queueName, final CloudQueueClient client) |
Creates an instance of the class using the specified name and client. |
CloudQueue(final URI uri) |
Creates an instance of the class using the specified queue URI. The queue must include a SAS token. |
CloudQueue(final URI uri, final StorageCredentials credentials) |
Creates an instance of the class using the specified queue and credentials. If the contains a SAS token, the credentials must be . |
Method Summary
Modifier and Type | Method and Description |
---|---|
void |
addMessage(final CloudQueueMessage message)
Adds a message to the back of the queue. |
void |
addMessage(final CloudQueueMessage message, final int timeToLiveInSeconds, final int initialVisibilityDelayInSeconds, QueueRequestOptions options, OperationContext opContext)
Adds a message to the back of the queue with the specified options. |
void |
clear()
Clears all messages from the queue. |
void |
clear(QueueRequestOptions options, OperationContext opContext)
Clears all messages from the queue, using the specified request options and operation context. |
void |
create()
Creates the queue. |
void |
create(QueueRequestOptions options, OperationContext opContext)
Creates the queue, using the specified request options and operation context. |
boolean |
createIfNotExists()
Creates the queue if it does not already exist. |
boolean |
createIfNotExists(QueueRequestOptions options, OperationContext opContext)
Creates the queue if it does not already exist, using the specified request options and operation context. |
void |
delete()
Deletes the queue. |
void |
delete(QueueRequestOptions options, OperationContext opContext)
Deletes the queue, using the specified request options and operation context. |
boolean |
deleteIfExists()
Deletes the queue if it exists. |
boolean |
deleteIfExists(QueueRequestOptions options, OperationContext opContext)
Deletes the queue if it exists, using the specified request options and operation context. |
void |
deleteMessage(final CloudQueueMessage message)
Deletes the specified message from the queue. |
void |
deleteMessage(final CloudQueueMessage message, QueueRequestOptions options, OperationContext opContext)
Deletes the specified message from the queue, using the specified request options and operation context. |
void |
downloadAttributes()
Downloads the queue's metadata and approximate message count value. |
void |
downloadAttributes(QueueRequestOptions options, OperationContext opContext)
Downloads the queue's metadata and approximate message count value, using the specified request options and operation context. |
Queue |
downloadPermissions()
Downloads the permission settings for the queue. |
Queue |
downloadPermissions(QueueRequestOptions options, OperationContext opContext)
Downloads the permissions settings for the queue using the specified request options and operation context. |
boolean |
exists()
Returns a value that indicates whether the queue exists. |
boolean |
exists(QueueRequestOptions options, OperationContext opContext)
Returns a value that indicates whether the queue existse, using the specified request options and operation context. |
String |
generateSharedAccessSignature(final SharedAccessQueuePolicy policy, final String groupPolicyIdentifier)
Returns a shared access signature for the queue. |
String |
generateSharedAccessSignature(final SharedAccessQueuePolicy policy, final String groupPolicyIdentifier, final IPRange ipRange, final SharedAccessProtocols protocols)
Returns a shared access signature for the queue. |
long |
getApproximateMessageCount()
Gets the approximate messages count of the queue. This value is initialized by a request to downloadAttributes() and represents the approximate message count when that request completed. |
HashMap<String, String> |
getMetadata()
Gets the metadata collection for the queue as stored in this object. This value is initialized with the metadata from the queue by a call to downloadAttributes(), and is set on the queue with a call to uploadMetadata(). |
String |
getName()
Gets the name of the queue. |
Cloud |
getServiceClient()
Gets the queue service client associated with this queue. |
boolean |
getShouldEncodeMessage()
Gets the value indicating whether the message should be base-64 encoded. |
final Storage |
getStorageUri()
Returns the list of URIs for all locations. |
URI |
getUri()
Gets the absolute URI for this queue. |
Cloud |
peekMessage()
Peeks a message from the queue. A peek request retrieves a message from the front of the queue without changing its visibility. |
Cloud |
peekMessage(final QueueRequestOptions options, final OperationContext opContext)
Peeks a message from the queue, using the specified request options and operation context. A peek request retrieves a message from the front of the queue without changing its visibility. |
Iterable<Cloud |
peekMessages(final int numberOfMessages)
Peeks a specified number of messages from the queue. A peek request retrieves messages from the front of the queue without changing their visibility. |
Iterable<Cloud |
peekMessages(final int numberOfMessages, QueueRequestOptions options, OperationContext opContext)
Peeks a set of messages from the queue, using the specified request options and operation context. A peek request retrieves messages from the front of the queue without changing their visibility. |
Cloud |
retrieveMessage()
Retrieves a message from the front of the queue using the default request options. This operation marks the retrieved message as invisible in the queue for the default visibility timeout period. |
Cloud |
retrieveMessage(final int visibilityTimeoutInSeconds, final QueueRequestOptions options, final OperationContext opContext)
Retrieves a message from the front of the queue, using the specified request options and operation context. This operation marks the retrieved message as invisible in the queue for the specified visibility timeout period. |
Iterable<Cloud |
retrieveMessages(final int numberOfMessages)
Retrieves the specified number of messages from the front of the queue using the default request options. This operation marks the retrieved messages as invisible in the queue for the default visibility timeout period. |
Iterable<Cloud |
retrieveMessages(final int numberOfMessages, final int visibilityTimeoutInSeconds, QueueRequestOptions options, OperationContext opContext)
Retrieves the specified number of messages from the front of the queue using the specified request options and operation context. This operation marks the retrieved messages as invisible in the queue for the default visibility timeout period. |
void |
setMetadata(final HashMap<String, String> metadata)
Sets the metadata collection of name-value pairs to be set on the queue with an uploadMetadata() call. This collection will overwrite any existing queue metadata. If this is set to an empty collection, the queue metadata will be cleared on an uploadMetadata() call. |
void |
setShouldEncodeMessage(final boolean shouldEncodeMessage)
Sets the flag indicating whether the message should be base-64 encoded. |
void |
updateMessage(final CloudQueueMessage message, final int visibilityTimeoutInSeconds)
Updates the specified message in the queue with a new visibility timeout value in seconds. |
void |
updateMessage(final CloudQueueMessage message, final int visibilityTimeoutInSeconds, final EnumSet<MessageUpdateFields> messageUpdateFields, QueueRequestOptions options, OperationContext opContext)
Updates a message in the queue, using the specified request options and operation context. |
void |
uploadMetadata()
Uploads the metadata in the object to the queue. |
void |
uploadMetadata(QueueRequestOptions options, OperationContext opContext)
Uploads the metadata in the object to the queue, using the specified request options and operation context. |
void |
uploadPermissions(final QueuePermissions permissions)
Uploads the queue's permissions. |
void |
uploadPermissions(final QueuePermissions permissions, QueueRequestOptions options, OperationContext opContext)
Uploads the queue's permissions using the specified request options and operation context. |
Constructor Details
CloudQueue
public CloudQueue(final StorageUri uri)
Creates an instance of the class using the specified queue . The queue must include a SAS token.
Parameters:
StorageUri
object that represents the absolute URI of the queue.
Throws:
CloudQueue
public CloudQueue(final StorageUri uri, final StorageCredentials credentials)
Creates an instance of the class using the specified queue and credentials. If the contains a SAS token, the credentials must be .
Parameters:
StorageUri
object that represents the absolute URI of the queue.
Throws:
CloudQueue
protected CloudQueue(final String queueName, final CloudQueueClient client)
Creates an instance of the class using the specified name and client.
Parameters:
Throws:
CloudQueue
public CloudQueue(final URI uri)
Creates an instance of the class using the specified queue URI. The queue must include a SAS token.
Parameters:
java.net.URI
object that represents the absolute URI of the queue.
Throws:
CloudQueue
public CloudQueue(final URI uri, final StorageCredentials credentials)
Creates an instance of the class using the specified queue and credentials. If the contains a SAS token, the credentials must be .
Parameters:
java.net.URI
object that represents the absolute URI of the queue.
Throws:
Method Details
addMessage
public void addMessage(final CloudQueueMessage message)
Adds a message to the back of the queue.
Parameters:
Throws:
addMessage
public void addMessage(final CloudQueueMessage message, final int timeToLiveInSeconds, final int initialVisibilityDelayInSeconds, QueueRequestOptions options, OperationContext opContext)
Adds a message to the back of the queue with the specified options.
Parameters:
null
will use the default request options from the associated service client ( CloudQueueClient).
Throws:
clear
public void clear()
Clears all messages from the queue.
Throws:
clear
public void clear(QueueRequestOptions options, OperationContext opContext)
Clears all messages from the queue, using the specified request options and operation context.
Parameters:
null
will use the default request options from the associated service client ( CloudQueueClient).
Throws:
create
public void create()
Creates the queue.
Throws:
create
public void create(QueueRequestOptions options, OperationContext opContext)
Creates the queue, using the specified request options and operation context.
Parameters:
null
will use the default request options from the associated service client ( CloudQueueClient).
Throws:
createIfNotExists
public boolean createIfNotExists()
Creates the queue if it does not already exist.
Returns:
true
if the queue is created in the storage service, otherwise false
Throws:
createIfNotExists
public boolean createIfNotExists(QueueRequestOptions options, OperationContext opContext)
Creates the queue if it does not already exist, using the specified request options and operation context.
Parameters:
null
will use the default request options from the associated service client ( CloudQueueClient).
Returns:
true
if the queue is created in the storage service, otherwise false
Throws:
delete
public void delete()
Deletes the queue.
Throws:
delete
public void delete(QueueRequestOptions options, OperationContext opContext)
Deletes the queue, using the specified request options and operation context.
Parameters:
null
will use the default request options from the associated service client ( CloudQueueClient).
Throws:
deleteIfExists
public boolean deleteIfExists()
Deletes the queue if it exists.
Returns:
true
if the queue existed in the storage service and has been deleted, otherwise false
.Throws:
deleteIfExists
public boolean deleteIfExists(QueueRequestOptions options, OperationContext opContext)
Deletes the queue if it exists, using the specified request options and operation context.
Parameters:
null
will use the default request options from the associated service client ( CloudQueueClient).
Returns:
true
if the queue existed in the storage service and has been deleted, otherwise false
.Throws:
deleteMessage
public void deleteMessage(final CloudQueueMessage message)
Deletes the specified message from the queue.
Parameters:
Throws:
deleteMessage
public void deleteMessage(final CloudQueueMessage message, QueueRequestOptions options, OperationContext opContext)
Deletes the specified message from the queue, using the specified request options and operation context.
Parameters:
null
will use the default request options from the associated service client ( CloudQueueClient).
Throws:
downloadAttributes
public void downloadAttributes()
Downloads the queue's metadata and approximate message count value.
Throws:
downloadAttributes
public void downloadAttributes(QueueRequestOptions options, OperationContext opContext)
Downloads the queue's metadata and approximate message count value, using the specified request options and operation context.
Parameters:
null
will use the default request options from the associated service client ( CloudQueue).
Throws:
downloadPermissions
public QueuePermissions downloadPermissions()
Downloads the permission settings for the queue.
Returns:
Throws:
downloadPermissions
public QueuePermissions downloadPermissions(QueueRequestOptions options, OperationContext opContext)
Downloads the permissions settings for the queue using the specified request options and operation context.
Parameters:
null
will use the default request options from the associated service client ( CloudQueueClient).
Returns:
Throws:
exists
public boolean exists()
Returns a value that indicates whether the queue exists.
Returns:
true
if the queue exists in the storage service, otherwise false
.
Throws:
exists
public boolean exists(QueueRequestOptions options, OperationContext opContext)
Returns a value that indicates whether the queue existse, using the specified request options and operation context.
Parameters:
null
will use the default request options from the associated service client ( CloudQueueClient).
Returns:
true
if the queue exists in the storage service, otherwise false
.
Throws:
generateSharedAccessSignature
public String generateSharedAccessSignature(final SharedAccessQueuePolicy policy, final String groupPolicyIdentifier)
Returns a shared access signature for the queue.
Parameters:
Returns:
Throws:
generateSharedAccessSignature
public String generateSharedAccessSignature(final SharedAccessQueuePolicy policy, final String groupPolicyIdentifier, final IPRange ipRange, final SharedAccessProtocols protocols)
Returns a shared access signature for the queue.
Parameters:
Returns:
Throws:
getApproximateMessageCount
public long getApproximateMessageCount()
Gets the approximate messages count of the queue. This value is initialized by a request to downloadAttributes() and represents the approximate message count when that request completed.
Returns:
Long
object that represents the approximate messages count of the queue.getMetadata
public HashMap
Gets the metadata collection for the queue as stored in this object. This value is initialized with the metadata from the queue by a call to downloadAttributes(), and is set on the queue with a call to uploadMetadata().
Returns:
java.util.HashMap
object that represents the metadata for the queue.getName
public String getName()
Gets the name of the queue.
Returns:
String
object that represents the name of the queue.getServiceClient
public CloudQueueClient getServiceClient()
Gets the queue service client associated with this queue.
Returns:
getShouldEncodeMessage
public boolean getShouldEncodeMessage()
Gets the value indicating whether the message should be base-64 encoded.
Returns:
Boolean
that represents whether the message should be base-64 encoded.getStorageUri
public final StorageUri getStorageUri()
Returns the list of URIs for all locations.
Returns:
StorageUri
that represents the list of URIs for all locations..getUri
public URI getUri()
Gets the absolute URI for this queue.
Returns:
java.net.URI
object that represents the URI for this queue.peekMessage
public CloudQueueMessage peekMessage()
Peeks a message from the queue. A peek request retrieves a message from the front of the queue without changing its visibility.
Returns:
Throws:
peekMessage
public CloudQueueMessage peekMessage(final QueueRequestOptions options, final OperationContext opContext)
Peeks a message from the queue, using the specified request options and operation context. A peek request retrieves a message from the front of the queue without changing its visibility.
Parameters:
null
will use the default request options from the associated service client ( CloudQueueClient).
Returns:
Throws:
peekMessages
public Iterable
Peeks a specified number of messages from the queue. A peek request retrieves messages from the front of the queue without changing their visibility.
Parameters:
Returns:
Throws:
peekMessages
public Iterable
Peeks a set of messages from the queue, using the specified request options and operation context. A peek request retrieves messages from the front of the queue without changing their visibility.
Parameters:
null
will use the default request options from the associated service client ( CloudQueueClient).
Returns:
Throws:
retrieveMessage
public CloudQueueMessage retrieveMessage()
Retrieves a message from the front of the queue using the default request options. This operation marks the retrieved message as invisible in the queue for the default visibility timeout period.
Returns:
Throws:
retrieveMessage
public CloudQueueMessage retrieveMessage(final int visibilityTimeoutInSeconds, final QueueRequestOptions options, final OperationContext opContext)
Retrieves a message from the front of the queue, using the specified request options and operation context. This operation marks the retrieved message as invisible in the queue for the specified visibility timeout period.
Parameters:
null
will use the default request options from the associated service client ( CloudQueueClient).
Returns:
Throws:
retrieveMessages
public Iterable
Retrieves the specified number of messages from the front of the queue using the default request options. This operation marks the retrieved messages as invisible in the queue for the default visibility timeout period.
Parameters:
Returns:
Throws:
retrieveMessages
public Iterable
Retrieves the specified number of messages from the front of the queue using the specified request options and operation context. This operation marks the retrieved messages as invisible in the queue for the default visibility timeout period.
Parameters:
null
will use the default request options from the associated service client ( CloudQueueClient).
Returns:
Throws:
setMetadata
public void setMetadata(final HashMap
Sets the metadata collection of name-value pairs to be set on the queue with an uploadMetadata() call. This collection will overwrite any existing queue metadata. If this is set to an empty collection, the queue metadata will be cleared on an uploadMetadata() call.
Parameters:
java.util.HashMap
object that represents the metadata being assigned to the queue.
setShouldEncodeMessage
public void setShouldEncodeMessage(final boolean shouldEncodeMessage)
Sets the flag indicating whether the message should be base-64 encoded.
Parameters:
updateMessage
public void updateMessage(final CloudQueueMessage message, final int visibilityTimeoutInSeconds)
Updates the specified message in the queue with a new visibility timeout value in seconds.
Parameters:
Throws:
updateMessage
public void updateMessage(final CloudQueueMessage message, final int visibilityTimeoutInSeconds, final EnumSet
Updates a message in the queue, using the specified request options and operation context.
Parameters:
EnumSet
of MessageUpdateFields values that specifies which parts of the message are to be updated.
null
will use the default request options from the associated service client ( CloudQueueClient).
Throws:
uploadMetadata
public void uploadMetadata()
Uploads the metadata in the object to the queue.
Throws:
uploadMetadata
public void uploadMetadata(QueueRequestOptions options, OperationContext opContext)
Uploads the metadata in the object to the queue, using the specified request options and operation context.
Parameters:
null
will use the default request options from the associated service client ( CloudQueueClient).
Throws:
uploadPermissions
public void uploadPermissions(final QueuePermissions permissions)
Uploads the queue's permissions.
Parameters:
Throws:
uploadPermissions
public void uploadPermissions(final QueuePermissions permissions, QueueRequestOptions options, OperationContext opContext)
Uploads the queue's permissions using the specified request options and operation context.
Parameters:
null
will use the default request options from the associated service client ( CloudQueueClient).
Throws:
Applies to
Azure SDK for Java