本文整理汇总了Java中com.microsoft.azure.storage.queue.CloudQueue类的典型用法代码示例。如果您正苦于以下问题:Java CloudQueue类的具体用法?Java CloudQueue怎么用?Java CloudQueue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CloudQueue类属于com.microsoft.azure.storage.queue包,在下文中一共展示了CloudQueue类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createQueue
import com.microsoft.azure.storage.queue.CloudQueue; //导入依赖的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.CloudQueue; //导入依赖的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: testQueueDownloadAttributes
import com.microsoft.azure.storage.queue.CloudQueue; //导入依赖的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
示例4: testCloudStorageAccountClientUriVerify
import com.microsoft.azure.storage.queue.CloudQueue; //导入依赖的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
示例5: getQueue
import com.microsoft.azure.storage.queue.CloudQueue; //导入依赖的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
示例6: sendMessage
import com.microsoft.azure.storage.queue.CloudQueue; //导入依赖的package包/类
/**
* 发送消息
* @param queue 队列
* @param message 消息内容
* @return 是否发送成功
*/
public static boolean sendMessage(CloudQueue queue, String message) {
DebugLog.d(TAG, "sendMessage() queue = " + queue + " , message = " + message);
try {
CloudQueueMessage queueMessage = new CloudQueueMessage(message);
queue.addMessage(queueMessage);
return true;
} catch (Exception e) {
DebugLog.e(TAG, "sendMessage()", e);
return false;
}
}
开发者ID:leleliu008,项目名称:Newton_for_Android_AS,代码行数:20,代码来源:AzureStorage.java
示例7: getSchemaNames
import com.microsoft.azure.storage.queue.CloudQueue; //导入依赖的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
示例8: peekMessages
import com.microsoft.azure.storage.queue.CloudQueue; //导入依赖的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
示例9: retrieveMessages
import com.microsoft.azure.storage.queue.CloudQueue; //导入依赖的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
示例10: deleteMessage
import com.microsoft.azure.storage.queue.CloudQueue; //导入依赖的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
示例11: testStartAsStartable
import com.microsoft.azure.storage.queue.CloudQueue; //导入依赖的package包/类
@Test
public void testStartAsStartable() {
AzureStorageQueueSource source = new AzureStorageQueueSource();
ValidationResult vr = source.initialize(getDummyRuntimeContiner(), properties);
assertNotNull(vr);
assertEquals(ValidationResult.OK.getStatus(), vr.getStatus());
reader = (AzureStorageQueueListReader) source.createReader(getDummyRuntimeContiner());
reader.queueService = queueService;
final List<CloudQueue> list = new ArrayList<>();
try {
list.add(new CloudQueue(new URI("https://storagesample.queue.core.windows.net/queue-1"), dummyCredential));
when(queueService.listQueues()).thenReturn(new Iterable<CloudQueue>() {
@Override
public Iterator<CloudQueue> iterator() {
return new DummyCloudQueueIterator(list);
}
});
assertTrue(reader.start());
} catch (InvalidKeyException | URISyntaxException | StorageException | IOException e) {
fail("should not throw " + e.getMessage());
}
}
开发者ID:Talend,项目名称:components,代码行数:29,代码来源:AzureStorageQueueListReaderTest.java
示例12: testStartAsNonStartable
import com.microsoft.azure.storage.queue.CloudQueue; //导入依赖的package包/类
@Test
public void testStartAsNonStartable() {
AzureStorageQueueSource source = new AzureStorageQueueSource();
ValidationResult vr = source.initialize(getDummyRuntimeContiner(), properties);
assertNotNull(vr);
assertEquals(ValidationResult.OK.getStatus(), vr.getStatus());
reader = (AzureStorageQueueListReader) source.createReader(getDummyRuntimeContiner());
reader.queueService = queueService;
final List<CloudQueue> list = new ArrayList<>();
try {
when(queueService.listQueues()).thenReturn(new Iterable<CloudQueue>() {
@Override
public Iterator<CloudQueue> iterator() {
return new DummyCloudQueueIterator(list);
}
});
assertFalse(reader.start());
} catch (InvalidKeyException | URISyntaxException | IOException e) {
fail("should not throw " + e.getMessage());
}
}
开发者ID:Talend,项目名称:components,代码行数:28,代码来源:AzureStorageQueueListReaderTest.java
示例13: testAdvanceAsAdvancable
import com.microsoft.azure.storage.queue.CloudQueue; //导入依赖的package包/类
@Test
public void testAdvanceAsAdvancable() {
AzureStorageQueueSource source = new AzureStorageQueueSource();
ValidationResult vr = source.initialize(getDummyRuntimeContiner(), properties);
assertNotNull(vr);
assertEquals(ValidationResult.OK.getStatus(), vr.getStatus());
reader = (AzureStorageQueueListReader) source.createReader(getDummyRuntimeContiner());
reader.queueService = queueService;
final List<CloudQueue> list = new ArrayList<>();
try {
list.add(new CloudQueue(new URI("https://storagesample.queue.core.windows.net/queue-1"), dummyCredential));
list.add(new CloudQueue(new URI("https://storagesample.queue.core.windows.net/queue-2"), dummyCredential));
when(queueService.listQueues()).thenReturn(new Iterable<CloudQueue>() {
@Override
public Iterator<CloudQueue> iterator() {
return new DummyCloudQueueIterator(list);
}
});
assertTrue(reader.start());
assertTrue(reader.advance());
} catch (InvalidKeyException | URISyntaxException | StorageException | IOException e) {
fail("should not throw " + e.getMessage());
}
}
开发者ID:Talend,项目名称:components,代码行数:31,代码来源:AzureStorageQueueListReaderTest.java
示例14: testAdvanceAsNonAdvancable
import com.microsoft.azure.storage.queue.CloudQueue; //导入依赖的package包/类
@Test
public void testAdvanceAsNonAdvancable() {
AzureStorageQueueSource source = new AzureStorageQueueSource();
ValidationResult vr = source.initialize(getDummyRuntimeContiner(), properties);
assertNotNull(vr);
assertEquals(ValidationResult.OK.getStatus(), vr.getStatus());
reader = (AzureStorageQueueListReader) source.createReader(getDummyRuntimeContiner());
reader.queueService = queueService;
final List<CloudQueue> list = new ArrayList<>();
try {
list.add(new CloudQueue(new URI("https://storagesample.queue.core.windows.net/queue-1"), dummyCredential));
when(queueService.listQueues()).thenReturn(new Iterable<CloudQueue>() {
@Override
public Iterator<CloudQueue> iterator() {
return new DummyCloudQueueIterator(list);
}
});
assertTrue(reader.start());
assertFalse(reader.advance());
} catch (InvalidKeyException | URISyntaxException | StorageException | IOException e) {
fail("should not throw " + e.getMessage());
}
}
开发者ID:Talend,项目名称:components,代码行数:30,代码来源:AzureStorageQueueListReaderTest.java
示例15: testAdvanceAsNonStartable
import com.microsoft.azure.storage.queue.CloudQueue; //导入依赖的package包/类
@Test
public void testAdvanceAsNonStartable() {
AzureStorageQueueSource source = new AzureStorageQueueSource();
ValidationResult vr = source.initialize(getDummyRuntimeContiner(), properties);
assertNotNull(vr);
assertEquals(ValidationResult.OK.getStatus(), vr.getStatus());
reader = (AzureStorageQueueListReader) source.createReader(getDummyRuntimeContiner());
reader.queueService = queueService;
final List<CloudQueue> list = new ArrayList<>();
try {
when(queueService.listQueues()).thenReturn(new Iterable<CloudQueue>() {
@Override
public Iterator<CloudQueue> iterator() {
return new DummyCloudQueueIterator(list);
}
});
assertFalse(reader.start());
assertFalse(reader.advance());
} catch (InvalidKeyException | URISyntaxException | IOException e) {
fail("should not throw " + e.getMessage());
}
}
开发者ID:Talend,项目名称:components,代码行数:29,代码来源:AzureStorageQueueListReaderTest.java
示例16: testGetCurrent
import com.microsoft.azure.storage.queue.CloudQueue; //导入依赖的package包/类
@Test
public void testGetCurrent() {
AzureStorageQueueSource source = new AzureStorageQueueSource();
ValidationResult vr = source.initialize(getDummyRuntimeContiner(), properties);
assertNotNull(vr);
assertEquals(ValidationResult.OK.getStatus(), vr.getStatus());
reader = (AzureStorageQueueListReader) source.createReader(getDummyRuntimeContiner());
reader.queueService = queueService;
final List<CloudQueue> list = new ArrayList<>();
try {
list.add(new CloudQueue(new URI("https://storagesample.queue.core.windows.net/queue-1"), dummyCredential));
when(queueService.listQueues()).thenReturn(new Iterable<CloudQueue>() {
@Override
public Iterator<CloudQueue> iterator() {
return new DummyCloudQueueIterator(list);
}
});
assertTrue(reader.start());
IndexedRecord current = reader.getCurrent();
assertNotNull(current);
assertEquals("queue-1", current.get(0));
} catch (InvalidKeyException | URISyntaxException | StorageException | IOException e) {
fail("should not throw " + e.getMessage());
}
}
开发者ID:Talend,项目名称:components,代码行数:31,代码来源:AzureStorageQueueListReaderTest.java
示例17: testGetCurrentWhenNotStartable
import com.microsoft.azure.storage.queue.CloudQueue; //导入依赖的package包/类
@Test(expected = NoSuchElementException.class)
public void testGetCurrentWhenNotStartable() {
AzureStorageQueueSource source = new AzureStorageQueueSource();
ValidationResult vr = source.initialize(getDummyRuntimeContiner(), properties);
assertNotNull(vr);
assertEquals(ValidationResult.OK.getStatus(), vr.getStatus());
reader = (AzureStorageQueueListReader) source.createReader(getDummyRuntimeContiner());
reader.queueService = queueService;
final List<CloudQueue> list = new ArrayList<>();
try {
when(queueService.listQueues()).thenReturn(new Iterable<CloudQueue>() {
@Override
public Iterator<CloudQueue> iterator() {
return new DummyCloudQueueIterator(list);
}
});
assertFalse(reader.start());
reader.getCurrent();
} catch (InvalidKeyException | URISyntaxException | IOException e) {
fail("should not throw " + e.getMessage());
}
}
开发者ID:Talend,项目名称:components,代码行数:28,代码来源:AzureStorageQueueListReaderTest.java
示例18: testGetCurrentWhenNotAdvancable
import com.microsoft.azure.storage.queue.CloudQueue; //导入依赖的package包/类
@Test(expected = NoSuchElementException.class)
public void testGetCurrentWhenNotAdvancable() {
AzureStorageQueueSource source = new AzureStorageQueueSource();
ValidationResult vr = source.initialize(getDummyRuntimeContiner(), properties);
assertNotNull(vr);
assertEquals(ValidationResult.OK.getStatus(), vr.getStatus());
reader = (AzureStorageQueueListReader) source.createReader(getDummyRuntimeContiner());
reader.queueService = queueService;
final List<CloudQueue> list = new ArrayList<>();
try {
list.add(new CloudQueue(new URI("https://storagesample.queue.core.windows.net/queue-1"), dummyCredential));
when(queueService.listQueues()).thenReturn(new Iterable<CloudQueue>() {
@Override
public Iterator<CloudQueue> iterator() {
return new DummyCloudQueueIterator(list);
}
});
assertTrue(reader.start());
assertFalse(reader.advance());
reader.getCurrent();
} catch (InvalidKeyException | URISyntaxException | IOException | StorageException e) {
fail("should not throw " + e.getMessage());
}
}
开发者ID:Talend,项目名称:components,代码行数:30,代码来源:AzureStorageQueueListReaderTest.java
示例19: testGetReturnValues
import com.microsoft.azure.storage.queue.CloudQueue; //导入依赖的package包/类
@Test
public void testGetReturnValues() {
AzureStorageQueueSource source = new AzureStorageQueueSource();
ValidationResult vr = source.initialize(getDummyRuntimeContiner(), properties);
assertNotNull(vr);
assertEquals(ValidationResult.OK.getStatus(), vr.getStatus());
reader = (AzureStorageQueueListReader) source.createReader(getDummyRuntimeContiner());
reader.queueService = queueService;
final List<CloudQueue> list = new ArrayList<>();
try {
list.add(new CloudQueue(new URI("https://storagesample.queue.core.windows.net/queue-1"), dummyCredential));
list.add(new CloudQueue(new URI("https://storagesample.queue.core.windows.net/queue-2"), dummyCredential));
list.add(new CloudQueue(new URI("https://storagesample.queue.core.windows.net/queue-3"), dummyCredential));
when(queueService.listQueues()).thenReturn(new Iterable<CloudQueue>() {
@Override
public Iterator<CloudQueue> iterator() {
return new DummyCloudQueueIterator(list);
}
});
assertTrue(reader.start());
while (reader.advance()) {
// read all records
}
Map<String, Object> returnedValues = reader.getReturnValues();
assertNotNull(returnedValues);
assertEquals(3, returnedValues.get(TAzureStorageQueueListDefinition.RETURN_NB_QUEUE));
} catch (InvalidKeyException | URISyntaxException | StorageException | IOException e) {
fail("should not throw " + e.getMessage());
}
}
开发者ID:Talend,项目名称:components,代码行数:37,代码来源:AzureStorageQueueListReaderTest.java
示例20: testUserAgentString
import com.microsoft.azure.storage.queue.CloudQueue; //导入依赖的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.CloudQueue类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论