本文整理汇总了Java中com.amazonaws.services.sqs.model.ListQueuesResult.getQueueUrls方法的典型用法代码示例。如果您正苦于以下问题:Java ListQueuesResult.getQueueUrls方法的具体用法?Java ListQueuesResult.getQueueUrls怎么用?Java ListQueuesResult.getQueueUrls使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.sqs.model.ListQueuesResult
的用法示例。
在下文中一共展示了ListQueuesResult.getQueueUrls方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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);
}
}
示例3: doStart
import com.amazonaws.services.sqs.model.ListQueuesResult; //导入方法依赖的package包/类
@Override
protected void doStart() throws Exception {
client = getConfiguration().getAmazonSQSClient() != null
? getConfiguration().getAmazonSQSClient() : getClient();
// Override the endpoint location
if (ObjectHelper.isNotEmpty(getConfiguration().getAmazonSQSEndpoint())) {
client.setEndpoint(getConfiguration().getAmazonSQSEndpoint());
}
// check the setting the headerFilterStrategy
if (headerFilterStrategy == null) {
headerFilterStrategy = new SqsHeaderFilterStrategy();
}
// If both region and Account ID is provided the queue URL can be built manually.
// This allows accessing queues where you don't have permission to list queues or query queues
if (configuration.getRegion() != null && configuration.getQueueOwnerAWSAccountId() != null) {
queueUrl = "https://sqs." + configuration.getRegion() + ".amazonaws.com/"
+ configuration.getQueueOwnerAWSAccountId() + "/" + configuration.getQueueName();
} else if (configuration.getQueueOwnerAWSAccountId() != null) {
GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest();
getQueueUrlRequest.setQueueName(configuration.getQueueName());
getQueueUrlRequest.setQueueOwnerAWSAccountId(configuration.getQueueOwnerAWSAccountId());
GetQueueUrlResult getQueueUrlResult = client.getQueueUrl(getQueueUrlRequest);
queueUrl = getQueueUrlResult.getQueueUrl();
} else {
// check whether the queue already exists
ListQueuesResult listQueuesResult = client.listQueues();
for (String url : listQueuesResult.getQueueUrls()) {
if (url.endsWith("/" + configuration.getQueueName())) {
queueUrl = url;
LOG.trace("Queue available at '{}'.", queueUrl);
break;
}
}
}
if (queueUrl == null) {
createQueue(client);
} else {
updateQueueAttributes(client);
}
}
示例4: listQueues
import com.amazonaws.services.sqs.model.ListQueuesResult; //导入方法依赖的package包/类
public List<String> listQueues(){
ListQueuesResult result= sqsClient.listQueues();
return result.getQueueUrls();
}