use of com.microsoft.azure.storage.queue.CloudQueue in project azure-tools-for-java by Microsoft.
the class StorageClientSDKManager method createQueueMessage.
public void createQueueMessage(@NotNull StorageAccount storageAccount, @NotNull QueueMessage queueMessage, int timeToLiveInSeconds) throws AzureCmdException {
try {
CloudQueueClient client = getCloudQueueClient(storageAccount);
CloudQueue cloudQueue = client.getQueueReference(queueMessage.getQueueName());
cloudQueue.addMessage(new CloudQueueMessage(queueMessage.getContent()), timeToLiveInSeconds, 0, null, null);
} catch (Throwable t) {
throw new AzureCmdException("Error creating the Queue Message", t);
}
}
use of com.microsoft.azure.storage.queue.CloudQueue 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);
}
}
use of com.microsoft.azure.storage.queue.CloudQueue 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);
}
}
use of com.microsoft.azure.storage.queue.CloudQueue in project camel by apache.
the class QueueServiceComponent method checkCredentials.
private void checkCredentials(QueueServiceConfiguration cfg) {
CloudQueue client = cfg.getAzureQueueClient();
StorageCredentials creds = client == null ? cfg.getCredentials() : client.getServiceClient().getCredentials();
if (creds == null) {
throw new IllegalArgumentException("Credentials must be specified.");
}
}
use of com.microsoft.azure.storage.queue.CloudQueue in project camel by apache.
the class QueueServiceProducer method updateMessage.
private void updateMessage(Exchange exchange) throws Exception {
CloudQueue client = QueueServiceUtil.createQueueClient(getConfiguration());
QueueServiceRequestOptions opts = QueueServiceUtil.getRequestOptions(exchange);
CloudQueueMessage message = getCloudQueueMessage(exchange);
LOG.trace("Updating the message in the queue [{}] from exchange [{}]...", getConfiguration().getQueueName(), exchange);
EnumSet<MessageUpdateFields> fields = null;
Object fieldsObject = exchange.getIn().getHeader(QueueServiceConstants.MESSAGE_UPDATE_FIELDS);
if (fieldsObject instanceof EnumSet) {
@SuppressWarnings("unchecked") EnumSet<MessageUpdateFields> theFields = (EnumSet<MessageUpdateFields>) fieldsObject;
fields = theFields;
} else if (fieldsObject instanceof MessageUpdateFields) {
fields = EnumSet.of((MessageUpdateFields) fieldsObject);
}
client.updateMessage(message, getConfiguration().getMessageVisibilityDelay(), fields, opts.getRequestOpts(), opts.getOpContext());
}
Aggregations