session.getProvenanceReporter().send(flowFile, cloudQueue.getUri().toString(), transmissionMillis);
attributes.put("azure.queue.uri", cloudQueue.getUri().toString()); attributes.put("azure.queue.insertionTime", message.getInsertionTime().toString()); attributes.put("azure.queue.expirationTime", message.getExpirationTime().toString());
public static CloudQueue getConfiguredClient(QueueServiceConfiguration cfg) { CloudQueue client = cfg.getAzureQueueClient(); if (client != null && !client.getUri().equals(prepareStorageQueueUri(cfg))) { throw new IllegalArgumentException("Invalid Client URI"); } return client; }
@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); } }
@NotNull public Queue createQueue(@NotNull StorageAccount storageAccount, @NotNull Queue queue) throws AzureCmdException { try { CloudQueueClient client = getCloudQueueClient(storageAccount); CloudQueue cloudQueue = client.getQueueReference(queue.getName()); cloudQueue.createIfNotExists(); cloudQueue.downloadAttributes(); String uri = cloudQueue.getUri() != null ? cloudQueue.getUri().toString() : ""; long approximateMessageCount = cloudQueue.getApproximateMessageCount(); queue.setUri(uri); queue.setApproximateMessageCount(approximateMessageCount); return queue; } catch (Throwable t) { throw new AzureCmdException("Error creating the Queue", t); } }
@Test public void testCloudStorageAccountClientUriVerify() throws URISyntaxException, StorageException { StorageCredentialsAccountAndKey cred = new StorageCredentialsAccountAndKey(ACCOUNT_NAME, ACCOUNT_KEY); CloudStorageAccount cloudStorageAccount = new CloudStorageAccount(cred, true); CloudBlobClient blobClient = cloudStorageAccount.createCloudBlobClient(); CloudBlobContainer container = blobClient.getContainerReference("container1"); assertEquals(cloudStorageAccount.getBlobEndpoint().toString() + "/container1", container.getUri().toString()); CloudQueueClient queueClient = cloudStorageAccount.createCloudQueueClient(); CloudQueue queue = queueClient.getQueueReference("queue1"); assertEquals(cloudStorageAccount.getQueueEndpoint().toString() + "/queue1", queue.getUri().toString()); CloudTableClient tableClient = cloudStorageAccount.createCloudTableClient(); CloudTable table = tableClient.getTableReference("table1"); assertEquals(cloudStorageAccount.getTableEndpoint().toString() + "/table1", table.getUri().toString()); CloudFileClient fileClient = cloudStorageAccount.createCloudFileClient(); CloudFileShare share = fileClient.getShareReference("share1"); assertEquals(cloudStorageAccount.getFileEndpoint().toString() + "/share1", share.getUri().toString()); }
@Test public void testQueueTypesWithStorageUri() throws URISyntaxException, StorageException { CloudQueueClient queueClient = TestHelper.createCloudQueueClient(); StorageUri endpoint = new StorageUri(new URI("http://" + ACCOUNT_NAME + QUEUE_SERVICE + ENDPOINT_SUFFIX), new URI("http://" + ACCOUNT_NAME + SECONDARY_SUFFIX + QUEUE_SERVICE + ENDPOINT_SUFFIX)); CloudQueueClient client = new CloudQueueClient(endpoint, queueClient.getCredentials()); assertEquals(endpoint, client.getStorageUri()); assertEquals(endpoint.getPrimaryUri(), client.getEndpoint()); StorageUri queueUri = new StorageUri(new URI(endpoint.getPrimaryUri() + "/queue"), new URI( endpoint.getSecondaryUri() + "/queue")); CloudQueue queue = client.getQueueReference("queue"); assertEquals(queueUri, queue.getStorageUri()); assertEquals(queueUri.getPrimaryUri(), queue.getUri()); assertEquals(endpoint, queue.getServiceClient().getStorageUri()); queue = new CloudQueue(queueUri, client.getCredentials()); assertEquals(queueUri, queue.getStorageUri()); assertEquals(queueUri.getPrimaryUri(), queue.getUri()); assertEquals(endpoint, queue.getServiceClient().getStorageUri()); }
@Test public void testQueueClientConstructor() throws URISyntaxException, StorageException { final CloudQueueClient qClient = TestHelper.createCloudQueueClient(); final String queueName = QueueTestHelper.generateRandomQueueName(); CloudQueue queue1 = qClient.getQueueReference(queueName); assertEquals(queueName, queue1.getName()); assertTrue(queue1.getUri().toString().endsWith(queueName)); assertEquals(qClient, queue1.getServiceClient()); CloudQueue queue2 = new CloudQueue(new URI(QueueTestHelper.appendQueueName(qClient.getEndpoint(), queueName)), qClient.getCredentials()); assertEquals(queueName, queue2.getName()); assertEquals(qClient.getCredentials(), queue2.getServiceClient().getCredentials()); }
Thread.sleep(30000); CloudQueue identifierSasQueue = new CloudQueue(PathUtility.addToQuery(this.queue.getUri(), this.queue.generateSharedAccessSignature(null, identifier))); identifierSasQueue.deleteMessage(message1); CloudQueue policySasQueue = new CloudQueue(PathUtility.addToQuery(this.queue.getUri(), this.queue.generateSharedAccessSignature(policy1, null))); policySasQueue.exists();
URI sasUri = sasClient.getQueueReference(queue.getName()).getUri(); sasUri = sasClient.getCredentials().transformUri(sasUri); final CloudQueue sasQueue = new CloudQueue(sasUri);