public final class QueueServiceAsyncClient extends Object
Instantiating an Asynchronous Queue Service Client
QueueServiceAsyncClient client = new QueueServiceClientBuilder()
.connectionString("connectionstring")
.endpoint("endpoint")
.buildAsyncClient();
View this for additional ways to construct the client.
| Modifier and Type | Method and Description |
|---|---|
Mono<QueueAsyncClient> |
createQueue(String queueName)
Creates a queue in the storage account with the specified name and returns a QueueAsyncClient to interact with
it.
|
Mono<com.azure.core.http.rest.Response<QueueAsyncClient>> |
createQueueWithResponse(String queueName,
Map<String,String> metadata)
Creates a queue in the storage account with the specified name and metadata and returns a QueueAsyncClient to
interact with it.
|
Mono<Void> |
deleteQueue(String queueName)
Deletes a queue in the storage account
|
Mono<com.azure.core.http.rest.Response<Void>> |
deleteQueueWithResponse(String queueName)
Deletes a queue in the storage account
|
String |
generateAccountSas(AccountSasSignatureValues accountSasSignatureValues)
Generates an account SAS for the Azure Storage account using the specified
AccountSasSignatureValues. |
String |
generateAccountSas(AccountSasSignatureValues accountSasSignatureValues,
com.azure.core.util.Context context)
Generates an account SAS for the Azure Storage account using the specified
AccountSasSignatureValues. |
String |
getAccountName()
Get associated account name.
|
com.azure.core.http.HttpPipeline |
getHttpPipeline()
Gets the
HttpPipeline powering this client. |
Mono<QueueServiceProperties> |
getProperties()
Retrieves the properties of the storage account's Queue service.
|
Mono<com.azure.core.http.rest.Response<QueueServiceProperties>> |
getPropertiesWithResponse()
Retrieves the properties of the storage account's Queue service.
|
QueueAsyncClient |
getQueueAsyncClient(String queueName)
Constructs a QueueAsyncClient that interacts with the specified queue.
|
String |
getQueueServiceUrl() |
QueueServiceVersion |
getServiceVersion()
Gets the service version the client is using.
|
Mono<QueueServiceStatistics> |
getStatistics()
Retrieves the geo replication information about the Queue service.
|
Mono<com.azure.core.http.rest.Response<QueueServiceStatistics>> |
getStatisticsWithResponse()
Retrieves the geo replication information about the Queue service.
|
com.azure.core.http.rest.PagedFlux<QueueItem> |
listQueues()
Lists all queues in the storage account without their metadata.
|
com.azure.core.http.rest.PagedFlux<QueueItem> |
listQueues(QueuesSegmentOptions options)
Lists the queues in the storage account that pass the filter.
|
Mono<Void> |
setProperties(QueueServiceProperties properties)
Sets the properties for the storage account's Queue service.
|
Mono<com.azure.core.http.rest.Response<Void>> |
setPropertiesWithResponse(QueueServiceProperties properties)
Sets the properties for the storage account's Queue service.
|
public String getQueueServiceUrl()
public QueueServiceVersion getServiceVersion()
public QueueAsyncClient getQueueAsyncClient(String queueName)
queueName - Name of the queuepublic Mono<QueueAsyncClient> createQueue(String queueName)
Code Samples
Create the queue "test"
client.createQueue("myqueue").subscribe(
response -> {
},
error -> System.err.print(error.toString()),
() -> System.out.println("Complete creating the queue!")
);
queueName - Name of the queueQueueAsyncClientQueueStorageException - If a queue with the same name and different metadata already existspublic Mono<com.azure.core.http.rest.Response<QueueAsyncClient>> createQueueWithResponse(String queueName, Map<String,String> metadata)
Code Samples
Create the queue "test" with metadata "queue:metadata"
client.createQueueWithResponse("myqueue", Collections.singletonMap("queue", "metadata"))
.subscribe(
response -> System.out.printf("Creating the queue with status code %d", response.getStatusCode()),
error -> System.err.print(error.toString()),
() -> System.out.println("Complete creating the queue!")
);
queueName - Name of the queuemetadata - Metadata to associate with the queue. If there is leading or trailing whitespace in any
metadata key or value, it must be removed or encoded.QueueAsyncClient and the status of creating the queueQueueStorageException - If a queue with the same name and different metadata already existspublic Mono<Void> deleteQueue(String queueName)
Code Samples
Delete the queue "test"
client.deleteQueue("myshare").subscribe(
response -> System.out.println("Deleting the queue completed.")
);
queueName - Name of the queueQueueStorageException - If the queue doesn't existpublic Mono<com.azure.core.http.rest.Response<Void>> deleteQueueWithResponse(String queueName)
Code Samples
Delete the queue "test"
client.deleteQueueWithResponse("myshare").subscribe(
response -> System.out.println("Deleting the queue completed with status code: " + response.getStatusCode())
);
queueName - Name of the queueQueueStorageException - If the queue doesn't existpublic com.azure.core.http.rest.PagedFlux<QueueItem> listQueues()
Code Samples
List all queues in the account
client.listQueues().subscribe(
queueItem -> System.out.printf("Queue %s exists in the account", queueItem.getName()),
error -> System.err.print(error.toString()),
() -> System.out.println("Complete listing the queues!")
);
For more information, see the Azure Docs.
Queues in the storage accountpublic com.azure.core.http.rest.PagedFlux<QueueItem> listQueues(QueuesSegmentOptions options)
includeMetadata to have metadata returned
for the queues.
Code Samples
List all queues that begin with "azure"
client.listQueues(new QueuesSegmentOptions().setPrefix("azure")).subscribe(
queueItem -> System.out.printf("Queue %s exists in the account and has metadata %s",
queueItem.getName(), queueItem.getMetadata()),
error -> System.err.print(error.toString()),
() -> System.out.println("Complete listing the queues!")
);
For more information, see the Azure Docs.
options - Options for listing queuesQueues in the storage account that satisfy the filter requirementspublic Mono<QueueServiceProperties> getProperties()
Code Samples
Retrieve Queue service properties
client.getProperties()
.subscribe(properties -> {
System.out.printf("Hour metrics enabled: %b, Minute metrics enabled: %b",
properties.getHourMetrics().isEnabled(), properties.getMinuteMetrics().isEnabled());
});
For more information, see the Azure Docs.
Queue service propertiespublic Mono<com.azure.core.http.rest.Response<QueueServiceProperties>> getPropertiesWithResponse()
Code Samples
Retrieve Queue service properties
client.getPropertiesWithResponse()
.subscribe(response -> {
QueueServiceProperties properties = response.getValue();
System.out.printf("Hour metrics enabled: %b, Minute metrics enabled: %b",
properties.getHourMetrics().isEnabled(), properties.getMinuteMetrics().isEnabled());
});
For more information, see the Azure Docs.
Queue service propertiespublic Mono<Void> setProperties(QueueServiceProperties properties)
null value for CORS. To disable all CORS in the Queue service pass an empty list for CORS.
Code Sample
Clear CORS in the Queue service
QueueServiceProperties properties = client.getProperties().block();
client.setProperties(properties)
.doOnSuccess(response -> System.out.println("Setting Queue service properties completed."));
Enable Minute and Hour Metrics
QueueServiceProperties properties = client.getProperties().block();
properties.getMinuteMetrics().setEnabled(true);
properties.getHourMetrics().setEnabled(true);
client.setProperties(properties).subscribe(
response -> System.out.println("Setting Queue service properties completed."));
For more information, see the Azure Docs.
properties - Storage account Queue service propertiesQueueStorageException - When one of the following is true
allowed headers, exposed headers, or allowed origins exceeds 256 characters.
Allowed methods isn't DELETE, GET, HEAD, MERGE, POST, OPTIONS, or
PUTpublic Mono<com.azure.core.http.rest.Response<Void>> setPropertiesWithResponse(QueueServiceProperties properties)
null value for CORS. To disable all CORS in the Queue service pass an empty list for CORS.
Code Sample
Clear CORS in the Queue service
QueueServiceProperties properties = client.getProperties().block();
client.setPropertiesWithResponse(properties)
.subscribe(response -> System.out.printf("Setting Queue service properties completed with status code %d",
response.getStatusCode()));
Enable Minute and Hour Metrics
QueueServiceProperties properties = client.getProperties().block();
properties.getMinuteMetrics().setEnabled(true);
properties.getHourMetrics().setEnabled(true);
client.setPropertiesWithResponse(properties)
.subscribe(response -> System.out.printf("Setting Queue service properties completed with status code %d",
response.getStatusCode()));
For more information, see the Azure Docs.
properties - Storage account Queue service propertiesQueueStorageException - When one of the following is true
allowed headers, exposed headers, or allowed origins exceeds 256 characters.
Allowed methods isn't DELETE, GET, HEAD, MERGE, POST, OPTIONS, or
PUTpublic Mono<QueueServiceStatistics> getStatistics()
Code Samples
Retrieve the geo replication information
client.getStatistics()
.subscribe(stats -> {
System.out.printf("Geo replication status: %s, Last synced: %s",
stats.getGeoReplication().getStatus(), stats.getGeoReplication().getLastSyncTime());
});
For more information, see the Azure Docs.
public Mono<com.azure.core.http.rest.Response<QueueServiceStatistics>> getStatisticsWithResponse()
Code Samples
Retrieve the geo replication information
client.getStatisticsWithResponse()
.subscribe(response -> {
QueueServiceStatistics stats = response.getValue();
System.out.printf("Geo replication status: %s, Last synced: %s",
stats.getGeoReplication().getStatus(), stats.getGeoReplication().getLastSyncTime());
});
For more information, see the Azure Docs.
public String getAccountName()
public com.azure.core.http.HttpPipeline getHttpPipeline()
HttpPipeline powering this client.public String generateAccountSas(AccountSasSignatureValues accountSasSignatureValues)
AccountSasSignatureValues.
Note : The client must be authenticated via StorageSharedKeyCredential
See AccountSasSignatureValues for more information on how to construct an account SAS.
The snippet below generates a SAS that lasts for two days and gives the user read and list access to queues and file shares.
AccountSasPermission permissions = new AccountSasPermission()
.setListPermission(true)
.setReadPermission(true);
AccountSasResourceType resourceTypes = new AccountSasResourceType().setContainer(true).setObject(true);
AccountSasService services = new AccountSasService().setQueueAccess(true).setFileAccess(true);
OffsetDateTime expiryTime = OffsetDateTime.now().plus(Duration.ofDays(2));
AccountSasSignatureValues sasValues =
new AccountSasSignatureValues(expiryTime, permissions, services, resourceTypes);
// Client must be authenticated via StorageSharedKeyCredential
String sas = queueServiceAsyncClient.generateAccountSas(sasValues);
accountSasSignatureValues - AccountSasSignatureValuesString representing the SAS query parameters.public String generateAccountSas(AccountSasSignatureValues accountSasSignatureValues, com.azure.core.util.Context context)
AccountSasSignatureValues.
Note : The client must be authenticated via StorageSharedKeyCredential
See AccountSasSignatureValues for more information on how to construct an account SAS.
The snippet below generates a SAS that lasts for two days and gives the user read and list access to queues and file shares.
AccountSasPermission permissions = new AccountSasPermission()
.setListPermission(true)
.setReadPermission(true);
AccountSasResourceType resourceTypes = new AccountSasResourceType().setContainer(true).setObject(true);
AccountSasService services = new AccountSasService().setQueueAccess(true).setFileAccess(true);
OffsetDateTime expiryTime = OffsetDateTime.now().plus(Duration.ofDays(2));
AccountSasSignatureValues sasValues =
new AccountSasSignatureValues(expiryTime, permissions, services, resourceTypes);
// Client must be authenticated via StorageSharedKeyCredential
String sas = queueServiceAsyncClient.generateAccountSas(sasValues, new Context("key", "value"));
accountSasSignatureValues - AccountSasSignatureValuescontext - Additional context that is passed through the code when generating a SAS.String representing the SAS query parameters.Copyright © 2021 Microsoft Corporation. All rights reserved.