本文整理汇总了Java中com.amazonaws.services.sqs.model.CreateQueueResult.getQueueUrl方法的典型用法代码示例。如果您正苦于以下问题:Java CreateQueueResult.getQueueUrl方法的具体用法?Java CreateQueueResult.getQueueUrl怎么用?Java CreateQueueResult.getQueueUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.sqs.model.CreateQueueResult
的用法示例。
在下文中一共展示了CreateQueueResult.getQueueUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initQueue
import com.amazonaws.services.sqs.model.CreateQueueResult; //导入方法依赖的package包/类
private void initQueue() {
this.sqs = new AmazonSQSClient(); // Do we need to use new
// ClientConfiguration().withMaxConnections(256)
// ?
this.sqs.configureRegion(region);
try {
// Check to see if queue exists
GetQueueUrlResult queueUrlResult = this.sqs.getQueueUrl(getSqsQueueName());
this.queueUrl = queueUrlResult.getQueueUrl();
} catch (QueueDoesNotExistException queueDoesNotExist) {
// Queue does not exist, need to create one
CreateQueueRequest createQueueRequest = new CreateQueueRequest();
createQueueRequest.setQueueName(getSqsQueueName());
createQueueRequest.addAttributesEntry("VisibilityTimeout", "" + getVisibilityTimeout());
CreateQueueResult createQueueResult = this.sqs.createQueue(createQueueRequest);
this.queueUrl = createQueueResult.getQueueUrl();
}
}
示例2: initialize
import com.amazonaws.services.sqs.model.CreateQueueResult; //导入方法依赖的package包/类
@Override
public void initialize(JSONObject config) throws Exception {
String endpoint = config.getString(PARAM_ENDPOINT);
String queueName = config.getString(GenericQueue.PARAM_NAME);
String accessKey = config.getString(PARAM_ACCESS_KEY);
String secretKey = config.getString(PARAM_SECRET_KEY);
if(accessKey==null) throw new Exception(PARAM_ACCESS_KEY+" is required!");
if(secretKey==null) throw new Exception(PARAM_SECRET_KEY+" is required!");
try {
this.client = new AmazonSQSAsyncClient(new BasicAWSCredentials(accessKey,secretKey));
this.client.setEndpoint(endpoint);
CreateQueueRequest createQueueRequest = new CreateQueueRequest(queueName);
CreateQueueResult createQueueResult = this.client.createQueue(createQueueRequest);
this.queueUrl = createQueueResult.getQueueUrl();
} catch (Throwable e){
throw new Exception(e);
}
}
示例3: resolveDestination
import com.amazonaws.services.sqs.model.CreateQueueResult; //导入方法依赖的package包/类
@Override
public String resolveDestination(String name) throws DestinationResolutionException {
String queueName = name;
if (this.resourceIdResolver != null) {
queueName = this.resourceIdResolver.resolveToPhysicalResourceId(name);
}
if (isValidQueueUrl(queueName)) {
return queueName;
}
if (this.autoCreate) {
//Auto-create is fine to be called even if the queue exists.
CreateQueueResult createQueueResult = this.amazonSqs.createQueue(new CreateQueueRequest(queueName));
return createQueueResult.getQueueUrl();
} else {
try {
GetQueueUrlResult getQueueUrlResult = this.amazonSqs.getQueueUrl(new GetQueueUrlRequest(queueName));
return getQueueUrlResult.getQueueUrl();
} catch (QueueDoesNotExistException e) {
throw new DestinationResolutionException(e.getMessage(), e);
}
}
}
示例4: getOrCreateQueue
import com.amazonaws.services.sqs.model.CreateQueueResult; //导入方法依赖的package包/类
@VisibleForTesting
String getOrCreateQueue() {
List<String> queueUrls = listQueues(queueName);
if (queueUrls == null || queueUrls.isEmpty()) {
CreateQueueRequest createQueueRequest = new CreateQueueRequest().withQueueName(queueName);
CreateQueueResult result = client.createQueue(createQueueRequest);
return result.getQueueUrl();
} else {
return queueUrls.get(0);
}
}
示例5: Scanner
import com.amazonaws.services.sqs.model.CreateQueueResult; //导入方法依赖的package包/类
public Scanner(ScanConfig config) {
opt = config;
ProfileCredentialsProvider creds = new ProfileCredentialsProvider(opt.profile());
creds.getCredentials(); // credible credential criteria
s3 = new AmazonS3Client(creds);
sqs = new AmazonSQSClient(creds);
CreateQueueResult queueResult = sqs.createQueue(opt.queue());
queueUrl = queueResult.getQueueUrl();
filter = Pattern.compile(opt.filter(), Pattern.CASE_INSENSITIVE);
max = Long.parseLong(opt.max());
}
示例6: createQueue
import com.amazonaws.services.sqs.model.CreateQueueResult; //导入方法依赖的package包/类
protected void createQueue(AmazonSQS client) {
LOG.trace("Queue '{}' doesn't exist. Will create it...", configuration.getQueueName());
// creates a new queue, or returns the URL of an existing one
CreateQueueRequest request = new CreateQueueRequest(configuration.getQueueName());
if (getConfiguration().getDefaultVisibilityTimeout() != null) {
request.getAttributes().put(QueueAttributeName.VisibilityTimeout.name(), String.valueOf(getConfiguration().getDefaultVisibilityTimeout()));
}
if (getConfiguration().getMaximumMessageSize() != null) {
request.getAttributes().put(QueueAttributeName.MaximumMessageSize.name(), String.valueOf(getConfiguration().getMaximumMessageSize()));
}
if (getConfiguration().getMessageRetentionPeriod() != null) {
request.getAttributes().put(QueueAttributeName.MessageRetentionPeriod.name(), String.valueOf(getConfiguration().getMessageRetentionPeriod()));
}
if (getConfiguration().getPolicy() != null) {
request.getAttributes().put(QueueAttributeName.Policy.name(), String.valueOf(getConfiguration().getPolicy()));
}
if (getConfiguration().getReceiveMessageWaitTimeSeconds() != null) {
request.getAttributes().put(QueueAttributeName.ReceiveMessageWaitTimeSeconds.name(), String.valueOf(getConfiguration().getReceiveMessageWaitTimeSeconds()));
}
if (getConfiguration().getRedrivePolicy() != null) {
request.getAttributes().put(QueueAttributeName.RedrivePolicy.name(), getConfiguration().getRedrivePolicy());
}
LOG.trace("Creating queue [{}] with request [{}]...", configuration.getQueueName(), request);
CreateQueueResult queueResult = client.createQueue(request);
queueUrl = queueResult.getQueueUrl();
LOG.trace("Queue created and available at: {}", queueUrl);
}
示例7: produceMsg
import com.amazonaws.services.sqs.model.CreateQueueResult; //导入方法依赖的package包/类
public void produceMsg(String[] msgs, boolean purgeFirst) throws Exception
{
CreateQueueResult res = sqs.createQueue(getCurrentQueueName());
if (purgeFirst) {
PurgeQueueRequest purgeReq = new PurgeQueueRequest(res.getQueueUrl());
sqs.purgeQueue(purgeReq);
}
for (String text : msgs) {
sqs.sendMessage(res.getQueueUrl(), text);
}
}
示例8: connectToQueue
import com.amazonaws.services.sqs.model.CreateQueueResult; //导入方法依赖的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);
}
}
示例9: getQueueArnFromAttributes
import com.amazonaws.services.sqs.model.CreateQueueResult; //导入方法依赖的package包/类
public void getQueueArnFromAttributes() {
String queueName = someQueueName();
CreateQueueResult createQueueResult = _amazonSQS.createQueue(new CreateQueueRequest(queueName));
String queueUrl = createQueueResult.getQueueUrl();
List<String> requestedAttributes = ImmutableList.of("QueueArn");
GetQueueAttributesResult getQueueAttributesResult = _amazonSQS.getQueueAttributes(new GetQueueAttributesRequest()
.withQueueUrl(queueUrl)
.withAttributeNames(requestedAttributes));
Map<String, String> resultAttributes = getQueueAttributesResult.getAttributes();
String queueArn = resultAttributes.get("QueueArn");
String queueNameFromArn = queueArn.substring(queueArn.lastIndexOf(":") + 1);
Assert.assertEquals(queueNameFromArn, queueName);
}
示例10: createQueueIfNotExists
import com.amazonaws.services.sqs.model.CreateQueueResult; //导入方法依赖的package包/类
private void createQueueIfNotExists() {
for (String qUrl : sqsClient.listQueues().getQueueUrls()) {
if (qUrl.contains(queueName)) {
queueUrl = qUrl;
break;
}
}
if (queueUrl == null) {
CreateQueueRequest request = new CreateQueueRequest(queueName);
Map<String, String> queueAttributes = new HashMap<String, String>();
queueAttributes.put("ReceiveMessageWaitTimeSeconds", Integer
.valueOf(receiveMessageWaitTimeout).toString());
if (messageDelay != null) {
queueAttributes.put("DelaySeconds", messageDelay.toString());
}
if (maximumMessageSize != null) {
queueAttributes.put("MaximumMessageSize",
maximumMessageSize.toString());
}
if (messageRetentionPeriod != null) {
queueAttributes.put("MessageRetentionPeriod",
messageRetentionPeriod.toString());
}
if (visibilityTimeout != null) {
queueAttributes.put("VisibilityTimeout",
visibilityTimeout.toString());
}
request.setAttributes(queueAttributes);
CreateQueueResult result = sqsClient.createQueue(request);
queueUrl = result.getQueueUrl();
log.debug("New queue available at: " + queueUrl);
} else {
log.debug("Queue already exists: " + queueUrl);
}
resolveQueueArn();
}
示例11: createMessageQueue
import com.amazonaws.services.sqs.model.CreateQueueResult; //导入方法依赖的package包/类
public String createMessageQueue(String queueName) {
CreateQueueResult createQueueResult = sqsClient.createQueue(queueName);
return createQueueResult.getQueueUrl();
}
示例12: someNewQueue
import com.amazonaws.services.sqs.model.CreateQueueResult; //导入方法依赖的package包/类
private String someNewQueue() {
final String queueName = someQueueName();
final CreateQueueResult queue = _amazonSQS.createQueue(new CreateQueueRequest(queueName));
return queue.getQueueUrl();
}
示例13: someNewQueue
import com.amazonaws.services.sqs.model.CreateQueueResult; //导入方法依赖的package包/类
private String someNewQueue() {
final String queueName = someQueueName();
final CreateQueueResult queue = _sqs1.createQueue(new CreateQueueRequest(queueName));
return queue.getQueueUrl();
}
示例14: someNewQueue
import com.amazonaws.services.sqs.model.CreateQueueResult; //导入方法依赖的package包/类
private String someNewQueue(String queueName) {
final CreateQueueResult queue = _amazonSQS1.createQueue(new CreateQueueRequest(queueName));
return queue.getQueueUrl();
}
示例15: createQueue
import com.amazonaws.services.sqs.model.CreateQueueResult; //导入方法依赖的package包/类
public String createQueue(String name){
CreateQueueRequest request=new CreateQueueRequest();
request.setQueueName(name);
CreateQueueResult res= sqsClient.createQueue(request);
return res.getQueueUrl();
}