/** * Gets a {@link CloudQueue} object with the specified name. * * @param 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. * @return A reference to a {@link CloudQueue} object. * @throws URISyntaxException * If the resource URI constructed based on the queueName is invalid. * @throws StorageException * If a storage service error occurred. * @see <a href="http://msdn.microsoft.com/en-us/library/azure/dd179349.aspx">Naming Queues and Metadata</a> */ public CloudQueue getQueueReference(final String queueName) throws URISyntaxException, StorageException { return new CloudQueue(queueName, this); }
/** * Gets a {@link CloudQueue} object with the specified name. * * @param 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. * @return A reference to a {@link CloudQueue} object. * @throws URISyntaxException * If the resource URI constructed based on the queueName is invalid. * @throws StorageException * If a storage service error occurred. * @see <a href="http://msdn.microsoft.com/en-us/library/azure/dd179349.aspx">Naming Queues and Metadata</a> */ public CloudQueue getQueueReference(final String queueName) throws URISyntaxException, StorageException { return new CloudQueue(queueName, this); }
public static CloudQueue createQueueClient(QueueServiceConfiguration cfg) throws Exception { CloudQueue client = getConfiguredClient(cfg); if (client == null) { URI uri = prepareStorageQueueUri(cfg); StorageCredentials creds = getAccountCredentials(cfg); client = new CloudQueue(uri, creds); } return client; }
@Test @Category({ DevFabricTests.class, DevStoreTests.class }) public void testSASClientParse() throws StorageException, InvalidKeyException, URISyntaxException { // Add a policy, check setting and getting. SharedAccessQueuePolicy policy1 = new SharedAccessQueuePolicy(); Calendar now = GregorianCalendar.getInstance(); now.add(Calendar.MINUTE, -15); policy1.setSharedAccessStartTime(now.getTime()); now.add(Calendar.MINUTE, 30); policy1.setSharedAccessExpiryTime(now.getTime()); policy1.setPermissions(EnumSet.of(SharedAccessQueuePermissions.READ, SharedAccessQueuePermissions.PROCESSMESSAGES, SharedAccessQueuePermissions.ADD, SharedAccessQueuePermissions.UPDATE)); String sasString = this.queue.generateSharedAccessSignature(policy1, null); URI queueUri = new URI("http://myaccount.queue.core.windows.net/myqueue"); CloudQueueClient queueClient1 = new CloudQueueClient(new URI("http://myaccount.queue.core.windows.net/"), new StorageCredentialsSharedAccessSignature(sasString)); CloudQueue queue1 = new CloudQueue(queueUri, queueClient1.getCredentials()); queue1.getName(); CloudQueueClient queueClient2 = new CloudQueueClient(new URI("http://myaccount.queue.core.windows.net/"), new StorageCredentialsSharedAccessSignature(sasString)); CloudQueue queue2 = new CloudQueue(queueUri, queueClient2.getCredentials()); queue2.getName(); }
@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(); CloudQueue queueFromUri = new CloudQueue(PathUtility.addToQuery(this.queue.getStorageUri(), this.queue.generateSharedAccessSignature(null, "readperm"))); assertEquals(StorageCredentialsSharedAccessSignature.class.toString(), queueFromUri.getServiceClient() queueClient.getDefaultRequestOptions().setRetryPolicyFactory(new RetryNoRetry()); queueFromUri = new CloudQueue(PathUtility.addToQuery(this.queue.getStorageUri(), this.queue.generateSharedAccessSignature(null, "readperm"))); assertEquals(StorageCredentialsSharedAccessSignature.class.toString(), queueFromUri.getServiceClient()
@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()); }
URI sasUri = sasClient.getQueueReference(queue.getName()).getUri(); sasUri = sasClient.getCredentials().transformUri(sasUri); final CloudQueue sasQueue = new CloudQueue(sasUri);