Search in sources :

Example 6 with CloudQueueClient

use of com.microsoft.azure.storage.queue.CloudQueueClient in project azure-tools-for-java by Microsoft.

the class StorageClientSDKManager method getQueues.

@NotNull
public List<Queue> getQueues(@NotNull StorageAccount storageAccount) throws AzureCmdException {
    List<Queue> qList = new ArrayList<Queue>();
    try {
        CloudQueueClient client = getCloudQueueClient(storageAccount);
        for (CloudQueue cloudQueue : client.listQueues(null, QueueListingDetails.ALL, null, null)) {
            String uri = cloudQueue.getUri() != null ? cloudQueue.getUri().toString() : "";
            qList.add(new Queue(Strings.nullToEmpty(cloudQueue.getName()), uri, cloudQueue.getApproximateMessageCount()));
        }
        return qList;
    } catch (Throwable t) {
        throw new AzureCmdException("Error retrieving the Queue list", t);
    }
}
Also used : CloudQueueClient(com.microsoft.azure.storage.queue.CloudQueueClient) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) CloudQueue(com.microsoft.azure.storage.queue.CloudQueue) Queue(com.microsoft.tooling.msservices.model.storage.Queue) CloudQueue(com.microsoft.azure.storage.queue.CloudQueue) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull)

Example 7 with CloudQueueClient

use of com.microsoft.azure.storage.queue.CloudQueueClient in project azure-tools-for-java by Microsoft.

the class StorageClientSDKManager method deleteQueue.

public void deleteQueue(@NotNull StorageAccount storageAccount, @NotNull Queue queue) throws AzureCmdException {
    try {
        CloudQueueClient client = getCloudQueueClient(storageAccount);
        CloudQueue cloudQueue = client.getQueueReference(queue.getName());
        cloudQueue.deleteIfExists();
    } catch (Throwable t) {
        throw new AzureCmdException("Error deleting the Queue", t);
    }
}
Also used : CloudQueueClient(com.microsoft.azure.storage.queue.CloudQueueClient) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) CloudQueue(com.microsoft.azure.storage.queue.CloudQueue)

Aggregations

CloudQueue (com.microsoft.azure.storage.queue.CloudQueue)7 CloudQueueClient (com.microsoft.azure.storage.queue.CloudQueueClient)7 AzureCmdException (com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)7 NotNull (com.microsoft.azuretools.azurecommons.helpers.NotNull)4 CloudQueueMessage (com.microsoft.azure.storage.queue.CloudQueueMessage)3 QueueMessage (com.microsoft.tooling.msservices.model.storage.QueueMessage)2 Queue (com.microsoft.tooling.msservices.model.storage.Queue)1