public final class CloudQueue extends Object
Modifier | Constructor and Description |
---|---|
|
CloudQueue(StorageUri uri)
Creates an instance of the
CloudQueue class using the specified queue StorageUri . |
|
CloudQueue(StorageUri uri,
StorageCredentials credentials)
Creates an instance of the
CloudQueue class using the specified queue StorageUri and
credentials. |
protected |
CloudQueue(String queueName,
CloudQueueClient client)
Creates an instance of the
CloudQueue class using the specified name and client. |
|
CloudQueue(URI uri)
Creates an instance of the
CloudQueue class using the specified queue URI. |
|
CloudQueue(URI uri,
StorageCredentials credentials)
Creates an instance of the
CloudQueue class using the specified queue URI and
credentials. |
Modifier and Type | Method and Description |
---|---|
void |
addMessage(CloudQueueMessage message)
Adds a message to the back of the queue.
|
void |
addMessage(CloudQueueMessage message,
int timeToLiveInSeconds,
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(CloudQueueMessage message)
Deletes the specified message from the queue.
|
void |
deleteMessage(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.
|
QueuePermissions |
downloadPermissions()
Downloads the permission settings for the queue.
|
QueuePermissions |
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(SharedAccessQueuePolicy policy,
String groupPolicyIdentifier)
Returns a shared access signature for the queue.
|
String |
generateSharedAccessSignature(SharedAccessQueuePolicy policy,
String groupPolicyIdentifier,
IPRange ipRange,
SharedAccessProtocols protocols)
Returns a shared access signature for the queue.
|
long |
getApproximateMessageCount()
Gets the approximate messages count of the queue.
|
HashMap<String,String> |
getMetadata()
Gets the metadata collection for the queue as stored in this
CloudQueue object. |
String |
getName()
Gets the name of the queue.
|
CloudQueueClient |
getServiceClient()
Gets the queue service client associated with this queue.
|
boolean |
getShouldEncodeMessage()
Gets the value indicating whether the message should be base-64 encoded.
|
StorageUri |
getStorageUri()
Returns the list of URIs for all locations.
|
URI |
getUri()
Gets the absolute URI for this queue.
|
CloudQueueMessage |
peekMessage()
Peeks a message from the queue.
|
CloudQueueMessage |
peekMessage(QueueRequestOptions options,
OperationContext opContext)
Peeks a message from the queue, using the specified request options and operation context.
|
Iterable<CloudQueueMessage> |
peekMessages(int numberOfMessages)
Peeks a specified number of messages from the queue.
|
Iterable<CloudQueueMessage> |
peekMessages(int numberOfMessages,
QueueRequestOptions options,
OperationContext opContext)
Peeks a set of messages from the queue, using the specified request options and operation context.
|
CloudQueueMessage |
retrieveMessage()
Retrieves a message from the front of the queue using the default request options.
|
CloudQueueMessage |
retrieveMessage(int visibilityTimeoutInSeconds,
QueueRequestOptions options,
OperationContext opContext)
Retrieves a message from the front of the queue, using the specified request options and operation context.
|
Iterable<CloudQueueMessage> |
retrieveMessages(int numberOfMessages)
Retrieves the specified number of messages from the front of the queue using the default request options.
|
Iterable<CloudQueueMessage> |
retrieveMessages(int numberOfMessages,
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.
|
void |
setMetadata(HashMap<String,String> metadata)
Sets the metadata collection of name-value pairs to be set on the queue with an
uploadMetadata() call. |
void |
setShouldEncodeMessage(boolean shouldEncodeMessage)
Sets the flag indicating whether the message should be base-64 encoded.
|
void |
updateMessage(CloudQueueMessage message,
int visibilityTimeoutInSeconds)
Updates the specified message in the queue with a new visibility timeout value in seconds.
|
void |
updateMessage(CloudQueueMessage message,
int visibilityTimeoutInSeconds,
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
CloudQueue object to the queue. |
void |
uploadMetadata(QueueRequestOptions options,
OperationContext opContext)
Uploads the metadata in the
CloudQueue object to the queue, using the specified request options and
operation context. |
void |
uploadPermissions(QueuePermissions permissions)
Uploads the queue's permissions.
|
void |
uploadPermissions(QueuePermissions permissions,
QueueRequestOptions options,
OperationContext opContext)
Uploads the queue's permissions using the specified request options and operation context.
|
public CloudQueue(URI uri) throws StorageException
CloudQueue
class using the specified queue URI. The queue
URI
must include a SAS token.uri
- A java.net.URI
object that represents the absolute URI of the queue.StorageException
- If a storage service error occurred.public CloudQueue(StorageUri uri) throws StorageException
CloudQueue
class using the specified queue StorageUri
. The
queue StorageUri
must include a SAS token.uri
- A StorageUri
object that represents the absolute URI of the queue.StorageException
- If a storage service error occurred.public CloudQueue(URI uri, StorageCredentials credentials) throws StorageException
CloudQueue
class using the specified queue URI
and
credentials. If the URI
contains a SAS token, the credentials must be null
.uri
- A java.net.URI
object that represents the absolute URI of the queue.credentials
- A StorageCredentials
object used to authenticate access.StorageException
- If a storage service error occurred.public CloudQueue(StorageUri uri, StorageCredentials credentials) throws StorageException
CloudQueue
class using the specified queue StorageUri
and
credentials. If the StorageUri
contains a SAS token, the credentials must be null
.uri
- A StorageUri
object that represents the absolute URI of the queue.credentials
- A StorageCredentials
object used to authenticate access.StorageException
- If a storage service error occurred.protected CloudQueue(String queueName, CloudQueueClient client) throws URISyntaxException, StorageException
CloudQueue
class using the specified name and client.queueName
- The name of the queue, which must adhere to queue naming rules. The queue name should not include any
path separator characters (/).
Queue names must be lowercase, between 3-63 characters long and must start with a letter or number.
Queue names may contain only letters, numbers, and the dash (-) character.client
- A CloudQueueClient
object that represents the associated service client, and that specifies
the endpoint for the Queue service.URISyntaxException
- If the resource URI constructed based on the queueName is invalid.StorageException
- If a storage service error occurred.@DoesServiceRequest public void addMessage(CloudQueueMessage message) throws StorageException
message
- A CloudQueueMessage
object that specifies the message to add.
The message object is modified to include the message ID and pop receipt,
and can be used in subsequent calls to updateMessage and deleteMessage.StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public void addMessage(CloudQueueMessage message, int timeToLiveInSeconds, int initialVisibilityDelayInSeconds, QueueRequestOptions options, OperationContext opContext) throws StorageException
message
- A CloudQueueMessage
object that specifies the message to add.
The message object is modified to include the message ID and pop receipt,
and can be used in subsequent calls to updateMessage and deleteMessage.timeToLiveInSeconds
- The maximum time to allow the message to be in the queue. A value of zero will set the time-to-live to
the service default value of seven days.initialVisibilityDelayInSeconds
- The length of time during which the message will be invisible, starting when it is added to the queue,
or 0 to make the message visible immediately. This value must be greater than or equal to zero and
less than or equal to the time-to-live value.options
- A QueueRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudQueueClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public void clear() throws StorageException
StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public void clear(QueueRequestOptions options, OperationContext opContext) throws StorageException
options
- A QueueRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudQueueClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public void create() throws StorageException
StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public void create(QueueRequestOptions options, OperationContext opContext) throws StorageException
options
- A QueueRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudQueueClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public boolean createIfNotExists() throws StorageException
true
if the queue is created in the storage service, otherwise false
.StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public boolean createIfNotExists(QueueRequestOptions options, OperationContext opContext) throws StorageException
options
- A QueueRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudQueueClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.true
if the queue is created in the storage service, otherwise false
.StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public void delete() throws StorageException
StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public void delete(QueueRequestOptions options, OperationContext opContext) throws StorageException
options
- A QueueRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudQueueClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public boolean deleteIfExists() throws StorageException
true
if the queue existed in the storage service and has been deleted, otherwise
false
.StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public boolean deleteIfExists(QueueRequestOptions options, OperationContext opContext) throws StorageException
options
- A QueueRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudQueueClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.true
if the queue existed in the storage service and has been deleted, otherwise
false
.StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public void deleteMessage(CloudQueueMessage message) throws StorageException
message
- A CloudQueueMessage
object that specifies the message to delete.StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public void deleteMessage(CloudQueueMessage message, QueueRequestOptions options, OperationContext opContext) throws StorageException
message
- A CloudQueueMessage
object that specifies the message to delete.options
- A QueueRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudQueueClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public void downloadAttributes() throws StorageException
StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public void downloadAttributes(QueueRequestOptions options, OperationContext opContext) throws StorageException
options
- A QueueRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudQueue
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public boolean exists() throws StorageException
true
if the queue exists in the storage service, otherwise false
.StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public boolean exists(QueueRequestOptions options, OperationContext opContext) throws StorageException
options
- A QueueRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudQueueClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.true
if the queue exists in the storage service, otherwise false
.StorageException
- If a storage service error occurred during the operation.public long getApproximateMessageCount()
downloadAttributes()
and represents the approximate message count when that request completed.Long
object that represents the approximate messages count of the queue.public HashMap<String,String> getMetadata()
CloudQueue
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()
.java.util.HashMap
object that represents the metadata for the queue.public String getName()
String
object that represents the name of the queue.public CloudQueueClient getServiceClient()
CloudQueueClient
object that represents the service client associated with this queue.public boolean getShouldEncodeMessage()
Boolean
that represents whether the message should be base-64 encoded.public final StorageUri getStorageUri()
StorageUri
that represents the list of URIs for all locations..public URI getUri()
java.net.URI
object that represents the URI for this queue.@DoesServiceRequest public CloudQueueMessage peekMessage() throws StorageException
CloudQueueMessage
object that represents a message in this queue.StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public CloudQueueMessage peekMessage(QueueRequestOptions options, OperationContext opContext) throws StorageException
options
- A QueueRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudQueueClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.CloudQueueMessage
object that represents the requested message from the queue.StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public Iterable<CloudQueueMessage> peekMessages(int numberOfMessages) throws StorageException
numberOfMessages
- The number of messages to retrieve.CloudQueueMessage
objects that represents the requested messages from
the queue.StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public Iterable<CloudQueueMessage> peekMessages(int numberOfMessages, QueueRequestOptions options, OperationContext opContext) throws StorageException
numberOfMessages
- The number of messages to retrieve.options
- A QueueRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudQueueClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.CloudQueueMessage
objects that represents the requested messages from
the queue.StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public CloudQueueMessage retrieveMessage() throws StorageException
CloudQueueMessage
object that represents a message in this queue.StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public CloudQueueMessage retrieveMessage(int visibilityTimeoutInSeconds, QueueRequestOptions options, OperationContext opContext) throws StorageException
visibilityTimeoutInSeconds
- Specifies the visibility timeout for the message, in seconds.options
- A QueueRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudQueueClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.CloudQueueMessage
object that represents a message in this queue.StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public Iterable<CloudQueueMessage> retrieveMessages(int numberOfMessages) throws StorageException
numberOfMessages
- The number of messages to retrieve.CloudQueueMessage
objects that represents the retrieved messages from
the queue.StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public Iterable<CloudQueueMessage> retrieveMessages(int numberOfMessages, int visibilityTimeoutInSeconds, QueueRequestOptions options, OperationContext opContext) throws StorageException
numberOfMessages
- The number of messages to retrieve.visibilityTimeoutInSeconds
- Specifies the visibility timeout for the retrieved messages, in seconds.options
- A QueueRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudQueueClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.CloudQueueMessage
objects that represents the messages retrieved from
the queue.StorageException
- If a storage service error occurred during the operation.public void setMetadata(HashMap<String,String> metadata)
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.metadata
- A java.util.HashMap
object that represents the metadata being assigned to the queue.public void setShouldEncodeMessage(boolean shouldEncodeMessage)
shouldEncodeMessage
- The value indicates whether the message should be base-64 encoded.public void updateMessage(CloudQueueMessage message, int visibilityTimeoutInSeconds) throws StorageException
message
- The CloudQueueMessage
to update in the queue.visibilityTimeoutInSeconds
- Specifies the new visibility timeout for the message, in seconds.StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public void updateMessage(CloudQueueMessage message, int visibilityTimeoutInSeconds, EnumSet<MessageUpdateFields> messageUpdateFields, QueueRequestOptions options, OperationContext opContext) throws StorageException
message
- The CloudQueueMessage
to update in the queue.visibilityTimeoutInSeconds
- Specifies the new visibility timeout for the message, in seconds.messageUpdateFields
- An EnumSet
of MessageUpdateFields
values that specifies which parts of the
message are to be updated.options
- A QueueRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudQueueClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public void uploadMetadata() throws StorageException
CloudQueue
object to the queue.StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public void uploadMetadata(QueueRequestOptions options, OperationContext opContext) throws StorageException
CloudQueue
object to the queue, using the specified request options and
operation context.options
- A QueueRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudQueueClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.StorageException
- If a storage service error occurred during the operation.@DoesServiceRequest public void uploadPermissions(QueuePermissions permissions) throws StorageException
permissions
- A QueuePermissions
object that represents the permissions to upload.StorageException
- If a storage service error occurred.@DoesServiceRequest public void uploadPermissions(QueuePermissions permissions, QueueRequestOptions options, OperationContext opContext) throws StorageException
permissions
- A QueuePermissions
object that represents the permissions to upload.options
- A QueueRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudQueueClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.StorageException
- If a storage service error occurred.@DoesServiceRequest public QueuePermissions downloadPermissions() throws StorageException
QueuePermissions
object that represents the queue's permissions.StorageException
- If a storage service error occurred.@DoesServiceRequest public QueuePermissions downloadPermissions(QueueRequestOptions options, OperationContext opContext) throws StorageException
options
- A QueueRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudQueueClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.QueuePermissions
object that represents the container's permissions.StorageException
- If a storage service error occurred.public String generateSharedAccessSignature(SharedAccessQueuePolicy policy, String groupPolicyIdentifier) throws InvalidKeyException, StorageException
policy
- The access policy for the shared access signature.groupPolicyIdentifier
- A queue-level access policy.InvalidKeyException
- If an invalid key was passed.StorageException
- If a storage service error occurred.IllegalArgumentException
- If an unexpected value is passed.public String generateSharedAccessSignature(SharedAccessQueuePolicy policy, String groupPolicyIdentifier, IPRange ipRange, SharedAccessProtocols protocols) throws InvalidKeyException, StorageException
policy
- The access policy for the shared access signature.groupPolicyIdentifier
- A queue-level access policy.ipRange
- A IPRange
object containing the range of allowed IP addresses.protocols
- A SharedAccessProtocols
representing the allowed Internet protocols.InvalidKeyException
- If an invalid key was passed.StorageException
- If a storage service error occurred.IllegalArgumentException
- If an unexpected value is passed.Copyright © 2019. All rights reserved.