当前位置: 首页>>代码示例>>Java>>正文


Java CloudQueueClient类代码示例

本文整理汇总了Java中com.microsoft.azure.storage.queue.CloudQueueClient的典型用法代码示例。如果您正苦于以下问题:Java CloudQueueClient类的具体用法?Java CloudQueueClient怎么用?Java CloudQueueClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CloudQueueClient类属于com.microsoft.azure.storage.queue包,在下文中一共展示了CloudQueueClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createQueue

import com.microsoft.azure.storage.queue.CloudQueueClient; //导入依赖的package包/类
/**
 * Creates and returns a queue for the sample application to use.
 *
 * @param queueClient CloudQueueClient object
 * @param queueName Name of the queue to create
 * @return The newly created CloudQueue object
 *
 * @throws StorageException
 * @throws RuntimeException
 * @throws IOException
 * @throws URISyntaxException
 * @throws IllegalArgumentException
 * @throws InvalidKeyException
 * @throws IllegalStateException
 */
private static CloudQueue createQueue(CloudQueueClient queueClient, String queueName) throws StorageException, RuntimeException, IOException, InvalidKeyException, IllegalArgumentException, URISyntaxException, IllegalStateException {

    // Create a new queue
    CloudQueue queue = queueClient.getQueueReference(queueName);
    try {
        if (queue.createIfNotExists() == false) {
            throw new IllegalStateException(String.format("Queue with name \"%s\" already exists.", queueName));
        }
    }
    catch (StorageException s) {
        if (s.getCause() instanceof java.net.ConnectException) {
            System.out.println("Caught connection exception from the client. If running with the default configuration please make sure you have started the storage emulator.");
        }
        throw s;
    }

    return queue;
}
 
开发者ID:Azure-Samples,项目名称:storage-queue-java-getting-started,代码行数:34,代码来源:QueueBasics.java

示例2: createQueueIfNotExists

import com.microsoft.azure.storage.queue.CloudQueueClient; //导入依赖的package包/类
/**
 * This method create a queue if it doesn't exist
 */
public boolean createQueueIfNotExists(String queueName) throws InvalidKeyException, URISyntaxException, StorageException {
    CloudQueueClient client = connection.getCloudStorageAccount().createCloudQueueClient();
    CloudQueue queueRef = client.getQueueReference(queueName);
    boolean creationResult;
    try {
        creationResult = queueRef.createIfNotExists();
    } catch (StorageException e) {
        if (!e.getErrorCode().equals(StorageErrorCodeStrings.QUEUE_BEING_DELETED)) {
            throw e;
        }
        LOGGER.warn(messages.getMessage("error.QueueDeleted", queueRef.getName()));
        // Documentation doesn't specify how many seconds at least to wait.
        // 40 seconds before retrying.
        // See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/delete-queue3
        try {
            Thread.sleep(40000);
        } catch (InterruptedException eint) {
            throw new RuntimeException(messages.getMessage("error.InterruptedException"));
        }
        creationResult = queueRef.createIfNotExists();
        LOGGER.debug(messages.getMessage("debug.QueueCreated", queueRef.getName()));
    }

    return creationResult;
}
 
开发者ID:Talend,项目名称:components,代码行数:29,代码来源:AzureStorageQueueService.java

示例3: callUploadServiceProps

import com.microsoft.azure.storage.queue.CloudQueueClient; //导入依赖的package包/类
private void callUploadServiceProps(
        ServiceClient client, ServiceProperties props, FileServiceProperties fileProps)
        throws StorageException, InterruptedException {

    if (client.getClass().equals(CloudBlobClient.class)) {
        ((CloudBlobClient) client).uploadServiceProperties(props);
    }
    else if (client.getClass().equals(CloudTableClient.class)) {
        ((CloudTableClient) client).uploadServiceProperties(props);
    }
    else if (client.getClass().equals(CloudQueueClient.class)) {
        ((CloudQueueClient) client).uploadServiceProperties(props);
    }
    else if (client.getClass().equals(CloudFileClient.class)) {
        ((CloudFileClient) client).uploadServiceProperties(fileProps);
    }
    else {
        fail();
    }

    Thread.sleep(30000);
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:23,代码来源:ServicePropertiesTests.java

示例4: callDownloadServiceProperties

import com.microsoft.azure.storage.queue.CloudQueueClient; //导入依赖的package包/类
private ServiceProperties callDownloadServiceProperties(ServiceClient client) throws StorageException {
    if (client.getClass().equals(CloudBlobClient.class)) {
        CloudBlobClient blobClient = (CloudBlobClient) client;
        return blobClient.downloadServiceProperties();
    }
    else if (client.getClass().equals(CloudTableClient.class)) {
        CloudTableClient tableClient = (CloudTableClient) client;
        return tableClient.downloadServiceProperties();
    }
    else if (client.getClass().equals(CloudQueueClient.class)) {
        CloudQueueClient queueClient = (CloudQueueClient) client;
        return queueClient.downloadServiceProperties();
    }
    else {
        fail();
    }
    return null;
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:19,代码来源:ServicePropertiesTests.java

示例5: testQueueDownloadAttributes

import com.microsoft.azure.storage.queue.CloudQueueClient; //导入依赖的package包/类
private static void testQueueDownloadAttributes(LocationMode optionsLocationMode, LocationMode clientLocationMode,
        StorageLocation initialLocation, List<RetryContext> retryContextList, List<RetryInfo> retryInfoList)
        throws URISyntaxException, StorageException {
    CloudQueueClient client = TestHelper.createCloudQueueClient();
    CloudQueue queue = client.getQueueReference(QueueTestHelper.generateRandomQueueName());

    MultiLocationTestHelper helper = new MultiLocationTestHelper(queue.getServiceClient().getStorageUri(),
            initialLocation, retryContextList, retryInfoList);

    queue.getServiceClient().getDefaultRequestOptions().setLocationMode(clientLocationMode);
    QueueRequestOptions options = new QueueRequestOptions();

    options.setLocationMode(optionsLocationMode);
    options.setRetryPolicyFactory(helper.retryPolicy);

    try {
        queue.downloadAttributes(options, helper.operationContext);
    }
    catch (StorageException ex) {
        assertEquals(HttpURLConnection.HTTP_NOT_FOUND, ex.getHttpStatusCode());
    }
    finally {
        helper.close();
    }
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:26,代码来源:SecondaryTests.java

示例6: testCloudStorageAccountClientUriVerify

import com.microsoft.azure.storage.queue.CloudQueueClient; //导入依赖的package包/类
@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());
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:22,代码来源:StorageAccountTests.java

示例7: createCloudQueueClient

import com.microsoft.azure.storage.queue.CloudQueueClient; //导入依赖的package包/类
/**
 * Creates a new Queue service client.
 * 
 * @return A client object that uses the Queue service endpoint.
 */
public CloudQueueClient createCloudQueueClient() {
    if (this.getQueueStorageUri() == null) {
        throw new IllegalArgumentException(SR.QUEUE_ENDPOINT_NOT_CONFIGURED);
    }

    if (this.credentials == null) {
        throw new IllegalArgumentException(SR.MISSING_CREDENTIALS);
    }

    if (!StorageCredentialsHelper.canCredentialsGenerateClient(this.credentials)) {
        
        throw new IllegalArgumentException(SR.CREDENTIALS_CANNOT_SIGN_REQUEST);
    }
    
    return new CloudQueueClient(this.getQueueStorageUri(), this.getCredentials());
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:22,代码来源:CloudStorageAccount.java

示例8: callUploadServiceProps

import com.microsoft.azure.storage.queue.CloudQueueClient; //导入依赖的package包/类
private void callUploadServiceProps(
        ServiceClient client, ServiceProperties props, FileServiceProperties fileProps)
        throws StorageException, InterruptedException {

    if (client.getClass().equals(CloudBlobClient.class)) {
        ((CloudBlobClient) client).uploadServiceProperties(props);
    }
    else if (client.getClass().equals(CloudTableClient.class)) {
        ((CloudTableClient) client).uploadServiceProperties(props);
    }
    else if (client.getClass().equals(CloudQueueClient.class)) {
        ((CloudQueueClient) client).uploadServiceProperties(props);
    }
    else if (client.getClass().equals(CloudFileClient.class)) {
        ((CloudFileClient) client).uploadServiceProperties(fileProps);
    }
    else {
        fail();
    }
    
    // It may take up to 30 seconds for the settings to take effect, but the new properties are immediately
    // visible when querying service properties.
}
 
开发者ID:Azure,项目名称:azure-storage-java,代码行数:24,代码来源:ServicePropertiesTests.java

示例9: getQueue

import com.microsoft.azure.storage.queue.CloudQueueClient; //导入依赖的package包/类
/**
 * 获取队列
 * @param queueClient  队列管理类
 * @param queueName    队列名
 * @return
 */
public static CloudQueue getQueue(CloudQueueClient queueClient, String queueName) {
	DebugLog.d(TAG, "getQueue() queueName = " + queueName);
	
	try {
		//获取队列,如果队列不存在,则创建队列
		CloudQueue queue = queueClient.getQueueReference(queueName);
		queue.createIfNotExists();
		
		return queue;
	} catch (Exception e) {
		DebugLog.e(TAG, "getQueue()", e);
		return null;
	}
}
 
开发者ID:leleliu008,项目名称:Newton_for_Android_AS,代码行数:21,代码来源:AzureStorage.java

示例10: getSchemaNames

import com.microsoft.azure.storage.queue.CloudQueueClient; //导入依赖的package包/类
@Override
public List<NamedThing> getSchemaNames(RuntimeContainer container) throws IOException {
    List<NamedThing> result = new ArrayList<>();
    try {
        CloudQueueClient client = getStorageQueueClient(container);
        for (CloudQueue q : client.listQueues()) {
            result.add(new SimpleNamedThing(q.getName(), q.getName()));
        }
    } catch (InvalidKeyException | URISyntaxException e) {
        throw new ComponentException(e);
    }
    return result;
}
 
开发者ID:Talend,项目名称:components,代码行数:14,代码来源:AzureStorageQueueSourceOrSink.java

示例11: peekMessages

import com.microsoft.azure.storage.queue.CloudQueueClient; //导入依赖的package包/类
public Iterable<CloudQueueMessage> peekMessages(String queueName, int numberOfMessages)
        throws InvalidKeyException, URISyntaxException, StorageException {

    CloudQueueClient client = connection.getCloudStorageAccount().createCloudQueueClient();
    CloudQueue queueRef = client.getQueueReference(queueName);
    return queueRef.peekMessages(numberOfMessages);
}
 
开发者ID:Talend,项目名称:components,代码行数:8,代码来源:AzureStorageQueueService.java

示例12: retrieveMessages

import com.microsoft.azure.storage.queue.CloudQueueClient; //导入依赖的package包/类
public Iterable<CloudQueueMessage> retrieveMessages(String queueName, int numberOfMessages)
        throws InvalidKeyException, URISyntaxException, StorageException {

    CloudQueueClient client = connection.getCloudStorageAccount().createCloudQueueClient();
    CloudQueue queueRef = client.getQueueReference(queueName);
    return queueRef.retrieveMessages(numberOfMessages);
}
 
开发者ID:Talend,项目名称:components,代码行数:8,代码来源:AzureStorageQueueService.java

示例13: deleteMessage

import com.microsoft.azure.storage.queue.CloudQueueClient; //导入依赖的package包/类
public void deleteMessage(String queueName, CloudQueueMessage message)
        throws InvalidKeyException, URISyntaxException, StorageException {

    CloudQueueClient client = connection.getCloudStorageAccount().createCloudQueueClient();
    CloudQueue queueRef = client.getQueueReference(queueName);
    queueRef.deleteMessage(message);
}
 
开发者ID:Talend,项目名称:components,代码行数:8,代码来源:AzureStorageQueueService.java

示例14: createCloudQueueClient

import com.microsoft.azure.storage.queue.CloudQueueClient; //导入依赖的package包/类
/**
 * Creates a new Queue service client.
 * 
 * @return A client object that uses the Queue service endpoint.
 */
public CloudQueueClient createCloudQueueClient() {
    if (this.getQueueStorageUri() == null) {
        throw new IllegalArgumentException(SR.QUEUE_ENDPOINT_NOT_CONFIGURED);
    }

    if (this.credentials == null) {
        throw new IllegalArgumentException(SR.MISSING_CREDENTIALS);
    }

    if (!StorageCredentialsHelper.canCredentialsSignRequest(this.credentials)) {
        throw new IllegalArgumentException(SR.CREDENTIALS_CANNOT_SIGN_REQUEST);
    }
    return new CloudQueueClient(this.getQueueStorageUri(), this.getCredentials());
}
 
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:20,代码来源:CloudStorageAccount.java

示例15: testUserAgentString

import com.microsoft.azure.storage.queue.CloudQueueClient; //导入依赖的package包/类
@Test
public void testUserAgentString() throws URISyntaxException, StorageException {
    // Test with a blob request
    CloudBlobClient blobClient = TestHelper.createCloudBlobClient();
    CloudBlobContainer container = blobClient.getContainerReference("container1");
    OperationContext sendingRequestEventContext = new OperationContext();
    sendingRequestEventContext.getSendingRequestEventHandler().addListener(new StorageEvent<SendingRequestEvent>() {

        @Override
        public void eventOccurred(SendingRequestEvent eventArg) {
            assertEquals(
                    Constants.HeaderConstants.USER_AGENT_PREFIX
                            + "/"
                            + Constants.HeaderConstants.USER_AGENT_VERSION
                            + " "
                            + String.format(Utility.LOCALE_US, "(Android %s; %s; %s)",
                            android.os.Build.VERSION.RELEASE, android.os.Build.BRAND,
                            android.os.Build.MODEL), ((HttpURLConnection) eventArg.getConnectionObject())
                            .getRequestProperty(Constants.HeaderConstants.USER_AGENT));
        }
    });
    container.exists(null, null, sendingRequestEventContext);

    // Test with a queue request
    CloudQueueClient queueClient = TestHelper.createCloudQueueClient();
    CloudQueue queue = queueClient.getQueueReference("queue1");
    queue.exists(null, sendingRequestEventContext);

    // Test with a table request
    CloudTableClient tableClient = TestHelper.createCloudTableClient();
    CloudTable table = tableClient.getTableReference("table1");
    table.exists(null, sendingRequestEventContext);
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:34,代码来源:GenericTests.java


注:本文中的com.microsoft.azure.storage.queue.CloudQueueClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。