本文整理汇总了Java中com.amazonaws.services.sqs.model.ListQueuesResult类的典型用法代码示例。如果您正苦于以下问题:Java ListQueuesResult类的具体用法?Java ListQueuesResult怎么用?Java ListQueuesResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ListQueuesResult类属于com.amazonaws.services.sqs.model包,在下文中一共展示了ListQueuesResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: check
import com.amazonaws.services.sqs.model.ListQueuesResult; //导入依赖的package包/类
@Override
protected Result check() throws Exception {
try {
ListQueuesResult listQueuesResult = sqs.listQueues();
if (listQueuesResult != null) {
return Result.healthy("OK");
}
else {
return Result.unhealthy("Could not fetch queues list from AWS");
}
} catch (AmazonClientException e) {
LOGGER.error(e.getMessage(),e);
return Result.unhealthy("Could not reach AWS to list queues");
}
}
示例2: oneQueue
import com.amazonaws.services.sqs.model.ListQueuesResult; //导入依赖的package包/类
@Test
public void oneQueue() {
AmazonSQS amazonSQS = mock(AmazonSQS.class);
// return one queue
when(amazonSQS.listQueues(any(ListQueuesRequest.class)))
.thenReturn(new ListQueuesResult().withQueueUrls("test-foo"));
// return 3 messages from the queue
when(amazonSQS.receiveMessage(any(ReceiveMessageRequest.class)))
.thenReturn(new ReceiveMessageResult().withMessages(newMessage("foo"), newMessage("foo"), newMessage("foo")));
AmazonSQSPrioritizedMessageProvider provider = new AmazonSQSPrioritizedMessageProvider(amazonSQS, "test", 1, 60 * 1000);
List<Message> messages = provider.next();
assertMessages(messages, 3, "foo");
verify(amazonSQS).listQueues(any(ListQueuesRequest.class));
verify(amazonSQS).receiveMessage(any(ReceiveMessageRequest.class));
}
示例3: testCreateGetUrlListQueue_shouldCreateReturnUrlAndListQueue
import com.amazonaws.services.sqs.model.ListQueuesResult; //导入依赖的package包/类
@Test
public void testCreateGetUrlListQueue_shouldCreateReturnUrlAndListQueue() {
// create first queue
CreateQueueResult createdQueue = sqs.createQueue(new CreateQueueRequest().withQueueName("tea-earl-grey-queue"));
assertNotNull("verify that, on creation, queue url was returned",createdQueue.getQueueUrl());
// create other queues
CreateQueueResult secondTeaQueue = sqs.createQueue(new CreateQueueRequest().withQueueName("tea-mate-queue"));
CreateQueueResult anotherQueue = sqs.createQueue(new CreateQueueRequest().withQueueName("coffee-queue"));
// get queue url
GetQueueUrlResult queueUrlResult = sqs.getQueueUrl(new GetQueueUrlRequest()
.withQueueName("tea-earl-grey-queue").withQueueOwnerAWSAccountId("some owner"));
assertNotNull("verify that, on fetch, queue url was returned", queueUrlResult.getQueueUrl());
// get all queues
ListQueuesResult allQueues = sqs.listQueues();
assertEquals("verify all queues are returned", 3, allQueues.getQueueUrls().size());
assertTrue("verify that all queues contain first queue", allQueues.getQueueUrls().contains(createdQueue.getQueueUrl()));
assertTrue("verify that all queues contain second tea queue", allQueues.getQueueUrls().contains(secondTeaQueue.getQueueUrl()));
assertTrue("verify that all queues contain coffee queue", allQueues.getQueueUrls().contains(anotherQueue.getQueueUrl()));
// get only queues that start with 'tea'
ListQueuesResult teaQueues = sqs.listQueues(new ListQueuesRequest("tea"));
assertEquals("verify only tea queues are returned", 2, teaQueues.getQueueUrls().size());
assertTrue("verify that tea queues contain first queue", teaQueues.getQueueUrls().contains(createdQueue.getQueueUrl()));
assertTrue("verify that tea queues contain second tea queue", teaQueues.getQueueUrls().contains(secondTeaQueue.getQueueUrl()));
assertNotNull("verify that delete queue returned ok", sqs.deleteQueue(new DeleteQueueRequest().withQueueUrl(queueUrlResult.getQueueUrl())));
assertFalse("verify that the queue was removed", sqs.listQueues().getQueueUrls().stream()
.anyMatch( queueUrl -> StringUtils.equals(queueUrl,queueUrlResult.getQueueUrl()) ));
// cleanup
getQueues().remove("tea-earl-grey-queue");
getQueues().remove("tea-mate-queue");
getQueues().remove("coffee-queue");
}
示例4: doStartShouldNotCallUpdateQueueAttributesIfQueueExistAndNoOptionIsSpecified
import com.amazonaws.services.sqs.model.ListQueuesResult; //导入依赖的package包/类
@Test
public void doStartShouldNotCallUpdateQueueAttributesIfQueueExistAndNoOptionIsSpecified() throws Exception {
EasyMock.expect(amazonSQSClient.listQueues())
.andReturn(new ListQueuesResult().withQueueUrls("https://sqs.us-east-1.amazonaws.com/ID/dummy-queue", "https://sqs.us-east-1.amazonaws.com/ID/test-queue"));
EasyMock.replay(amazonSQSClient);
endpoint.doStart();
EasyMock.verify(amazonSQSClient);
}
示例5: listQueues
import com.amazonaws.services.sqs.model.ListQueuesResult; //导入依赖的package包/类
@Override
public ListQueuesResult listQueues() throws AmazonServiceException, AmazonClientException {
ListQueuesResult result = new ListQueuesResult();
result.getQueueUrls().add("http://queue.amazonaws.com/0815/Foo");
result.getQueueUrls().add("http://queue.amazonaws.com/0815/MyQueue");
result.getQueueUrls().add("http://queue.amazonaws.com/0815/Bar");
return result;
}
示例6: generateCurrentQueueName
import com.amazonaws.services.sqs.model.ListQueuesResult; //导入依赖的package包/类
/**
* Each test creates its own uniquely named queue in SQS and then deletes it afterwards.
* We try to scrub any leftover queues from the previous runs just in case tests were
* aborted
*
* @param currentQueueNamePrefix
*/
public void generateCurrentQueueName(String currentQueueNamePrefix)
{
if (validateTestCreds()) {
ListQueuesResult list = sqs.listQueues(currentQueueNamePrefix);
for (String url : list.getQueueUrls()) {
sqs.deleteQueue(url);
}
}
this.currentQueueName = currentQueueNamePrefix + System.currentTimeMillis();
}
示例7: shouldBeHealthy
import com.amazonaws.services.sqs.model.ListQueuesResult; //导入依赖的package包/类
@Test
public void shouldBeHealthy() throws Exception {
//GIVEN
String queueUrl1 = "https://eu-central-1/queue.amazonaws.com/123456/test-queue";
when(sqs.listQueues()).thenReturn(new ListQueuesResult().withQueueUrls(queueUrl1));
//WHEN
HealthCheck.Result result = sqsBundleHealthCheck.check();
//THEN
assertThat(result.isHealthy()).isTrue();
}
示例8: createQueue
import com.amazonaws.services.sqs.model.ListQueuesResult; //导入依赖的package包/类
@Test
public void createQueue() {
final String queueName = "bizo";
final CreateQueueRequest createQueueRequest = new CreateQueueRequest().withQueueName(queueName);
sqs.createQueue(createQueueRequest);
final ListQueuesResult listQueuesResult = sqs.listQueues();
assertThat(listQueuesResult.getQueueUrls(), hasItem(containsString(queueName)));
}
示例9: connectToQueue
import com.amazonaws.services.sqs.model.ListQueuesResult; //导入依赖的package包/类
/**
* Note here we attempt to the TOCQueue which may take some time to be shown as available
* @param isConsumer
* @param maxAttempts
* @throws Exception
*/
public void connectToQueue(boolean isConsumer, int maxAttempts) throws Exception{
for (int i=0; i<maxAttempts; i++) {
logger.debug("connectToQueue() attempt: " + (i+1));
ListQueuesResult queuesResult = sqsClient.listQueues();
if (queuesResult != null) {
for (String queueUrl : queuesResult.getQueueUrls()) {
if (queueUrl.indexOf(sqsQueueName) != -1) {
tocQueueUrl = queueUrl;
break;
}
}
}
// if consumer, retry, otherwise is master, so just exit quick to create...
if (tocQueueUrl == null && isConsumer) {
Thread.currentThread().sleep(1000);
continue;
} else {
break; // exit;
}
}
if (tocQueueUrl == null && !isConsumer) {
CreateQueueResult createQueueResult = sqsClient.createQueue(sqsQueueName);
this.tocQueueUrl = createQueueResult.getQueueUrl();
} else if (tocQueueUrl == null) {
throw new Exception("TOCQueue() isConsumer:"+ isConsumer+ " cannot start, sqsQueueName has yet to be created by master?: " + sqsQueueName);
}
}
示例10: listQueues
import com.amazonaws.services.sqs.model.ListQueuesResult; //导入依赖的package包/类
@Override
public ListQueuesResult listQueues(ListQueuesRequest listQueuesRequest) throws AmazonClientException {
List<String> queueUrls = Lists.newArrayListWithCapacity(_queuesByUrl.size());
try (DirectoryStream<Path> queuePaths = Files.newDirectoryStream(_rootDirectory.toPath())) {
for (Path queuePath : queuePaths) {
if (listQueuesRequest.getQueueNamePrefix() == null || queuePath.getFileName().toString().startsWith(listQueuesRequest.getQueueNamePrefix())) {
queueUrls.add(queuePath.toUri().toString());
}
}
} catch (IOException e) {
throw new AmazonServiceException("could not get queue list", e);
}
return new ListQueuesResult().withQueueUrls(queueUrls);
}
示例11: updateAvailableQueues
import com.amazonaws.services.sqs.model.ListQueuesResult; //导入依赖的package包/类
private void updateAvailableQueues() {
try {
ListQueuesResult result = sqs.listQueues(new ListQueuesRequest(queuePrefix));
List<String> availableQueues = Lists.newArrayList(Iterables.filter(result.getQueueUrls(), include));
Collections.sort(availableQueues, queueComparator);
messageProviders.clear();
for (String queueUrl : availableQueues) {
messageProviders.add(new AmazonSQSMessageProvider(sqs, queueUrl, waitTimeSeconds));
}
} catch (AmazonClientException e) {
LOG.error("An error occurred while listing SQS queues: {}", e);
}
}
示例12: noQueues
import com.amazonaws.services.sqs.model.ListQueuesResult; //导入依赖的package包/类
@Test
public void noQueues() {
AmazonSQS amazonSQS = mock(AmazonSQS.class);
// return an empty list
when(amazonSQS.listQueues(any(ListQueuesRequest.class))).thenReturn(new ListQueuesResult());
AmazonSQSPrioritizedMessageProvider provider = new AmazonSQSPrioritizedMessageProvider(amazonSQS, "test", 1, 10 * 1000);
List<Message> empty = provider.next();
Assert.assertEquals(0, empty.size());
verify(amazonSQS).listQueues(any(ListQueuesRequest.class));
}
示例13: listQueues
import com.amazonaws.services.sqs.model.ListQueuesResult; //导入依赖的package包/类
@Override
public Either<HttpFailure,ListQueuesResult> listQueues() {
return new AwsSQSHttpClosure<ListQueuesResult>(client_, SC_OK,
new ListQueuesResultStaxUnmarshaller()) {
@Override
public void prepare(final AwsHttpRequest request) throws Exception {
request.addParameter(SQS_ACTION_PARAM, SQS_ACTION_LIST_QUEUES);
}
}.post();
}
示例14: listQueues
import com.amazonaws.services.sqs.model.ListQueuesResult; //导入依赖的package包/类
private List<String> listQueues(String queueName) {
ListQueuesRequest listQueuesRequest = new ListQueuesRequest().withQueueNamePrefix(queueName);
ListQueuesResult resultList = client.listQueues(listQueuesRequest);
List<String> queueUrls = resultList.getQueueUrls().stream().filter(queueUrl -> queueUrl.contains(queueName)).collect(Collectors.toList());
return queueUrls;
}
示例15: listQueuesAsync
import com.amazonaws.services.sqs.model.ListQueuesResult; //导入依赖的package包/类
public Observable<ListQueuesResult> listQueuesAsync(ListQueuesRequest request) {
return Observable.from(sqsClient.listQueuesAsync(request));
}