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


Java CreateQueueResult类代码示例

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


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

示例1: testPurgeQueue_shouldRemoveAll

import com.amazonaws.services.sqs.model.CreateQueueResult; //导入依赖的package包/类
@Test
public void testPurgeQueue_shouldRemoveAll() {
  // create queue
  CreateQueueResult createdQueue = sqs.createQueue(new CreateQueueRequest().withQueueName("tea-earl-grey-queue"));
  // send messages
  String messageBody = "{\"life-universe-everything\":42}";
  sqs.sendMessage(new SendMessageRequest().withDelaySeconds(0).withMessageBody(messageBody)
      .withMessageGroupId("some-group-id-123").withQueueUrl(createdQueue.getQueueUrl()));
  String messageBody2 = "{\"dead-emptyness-nothing\":24}";
  sqs.sendMessage(new SendMessageRequest().withDelaySeconds(0).withMessageBody(messageBody2)
      .withMessageGroupId("some-group-id-123").withQueueUrl(createdQueue.getQueueUrl()));
  
  // purge queues
  PurgeQueueResult result = sqs.purgeQueue(new PurgeQueueRequest().withQueueUrl(createdQueue.getQueueUrl()));
  assertNotNull("verify that purge queue returned ok", result);
  
  // verify empty queue
  ReceiveMessageResult messageResult = sqs.receiveMessage(new ReceiveMessageRequest()
      .withMaxNumberOfMessages(9).withQueueUrl(createdQueue.getQueueUrl()).withVisibilityTimeout(10)
      .withWaitTimeSeconds(0));
  assertEquals("verify that queue is empty", 0, messageResult.getMessages().size());
  
  // cleanup
  getQueues().remove("tea-earl-grey-queue");
}
 
开发者ID:daflockinger,项目名称:unitstack,代码行数:26,代码来源:MockSqsTest.java

示例2: shouldCreateNewQueueWhenNoQueueUrlIsFound

import com.amazonaws.services.sqs.model.CreateQueueResult; //导入依赖的package包/类
@Test
public void shouldCreateNewQueueWhenNoQueueUrlIsFound() throws Exception {
    //GIVEN
    AmazonSQS sqs = mock(AmazonSQS.class);
    field("sqs").ofType(AmazonSQS.class).in(bundle).set(sqs);

    String queueUrl = "https://eu-central-1/queue.amazonaws.com/123456/test-queue";
    when(sqs.getQueueUrl("test-queue")).thenThrow(new QueueDoesNotExistException("Simulates that queue does not exist"));
    when(sqs.createQueue(new CreateQueueRequest("test-queue"))).thenReturn(new CreateQueueResult().withQueueUrl(queueUrl));

    //WHEN
    Optional<String> urlForQueue = bundle.getUrlForQueue("test-queue");

    //THEN
    assertThat(urlForQueue.isPresent()).isTrue();
    assertThat(urlForQueue.get()).isEqualTo(queueUrl);
}
 
开发者ID:sjarrin,项目名称:dropwizard-sqs-bundle,代码行数:18,代码来源:SqsBundleTest.java

示例3: 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();
	}
}
 
开发者ID:olegdulin,项目名称:sqs-retryqueue,代码行数:19,代码来源:SQSRetryQueue.java

示例4: 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);
    }
}
 
开发者ID:mychaelstyle,项目名称:generic-queue,代码行数:19,代码来源:AwsSQS.java

示例5: 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);
        }
    }
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:26,代码来源:DynamicQueueUrlDestinationResolver.java

示例6: testAssertQueueAlreadyExistsAndMatches

import com.amazonaws.services.sqs.model.CreateQueueResult; //导入依赖的package包/类
@Test
public void testAssertQueueAlreadyExistsAndMatches() {
    when(requestSenderMock.sendRequest(any(CreateQueueAction.class))).thenReturn(Single.just(
            new CreateQueueResult().withQueueUrl(QUEUE_URL)
    ));
    SqsQueue<String> queue = client.upsertQueue(QUEUE_CONFIG).blockingGet();
    assertThat(queue.getQueueUrl()).isEqualTo(QUEUE_URL);
    verify(requestSenderMock).sendRequest(any(CreateQueueAction.class));
}
 
开发者ID:Bandwidth,项目名称:async-sqs,代码行数:10,代码来源:SqsClientTest.java

示例7: testCreateGetUrlListQueue_shouldCreateReturnUrlAndListQueue

import com.amazonaws.services.sqs.model.CreateQueueResult; //导入依赖的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");
}
 
开发者ID:daflockinger,项目名称:unitstack,代码行数:35,代码来源:MockSqsTest.java

示例8: 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);
       }
   }
 
开发者ID:Netflix,项目名称:conductor,代码行数:12,代码来源:SQSObservableQueue.java

示例9: 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());
}
 
开发者ID:jhy,项目名称:RekognitionS3Batch,代码行数:14,代码来源:Scanner.java

示例10: main

import com.amazonaws.services.sqs.model.CreateQueueResult; //导入依赖的package包/类
public static void main(String[] args)
{
    final String queue_name = "testQueue" + new Date().getTime();
    AmazonSQS sqs = AmazonSQSClientBuilder.defaultClient();

    // first, create a queue (unless it exists already)
    try {
        CreateQueueResult cq_result = sqs.createQueue(queue_name);
    } catch (AmazonSQSException e) {
        if (!e.getErrorCode().equals("QueueAlreadyExists")) {
            throw e;
        }
    }

    final String queue_url = sqs.getQueueUrl(queue_name).getQueueUrl();

    // Send some messages to the queue
    for (int i = 0; i < 20; i++) {
        sqs.sendMessage(queue_url, "This is message " + i);
    }

    // change visibility timeout (single)
    changeMessageVisibilitySingle(queue_url, 3600);

    // change visibility timeout (multiple)
    changeMessageVisibilityMultiple(queue_url, 2000);
}
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:28,代码来源:VisibilityTimeout.java

示例11: main

import com.amazonaws.services.sqs.model.CreateQueueResult; //导入依赖的package包/类
public static void main(String[] args)
{
    final AmazonSQS sqs = AmazonSQSClientBuilder.defaultClient();

    try {
        CreateQueueResult create_result = sqs.createQueue(QUEUE_NAME);
    } catch (AmazonSQSException e) {
        if (!e.getErrorCode().equals("QueueAlreadyExists")) {
            throw e;
        }
    }

    String queueUrl = sqs.getQueueUrl(QUEUE_NAME).getQueueUrl();

    SendMessageRequest send_msg_request = new SendMessageRequest()
            .withQueueUrl(queueUrl)
            .withMessageBody("hello world")
            .withDelaySeconds(5);
    sqs.sendMessage(send_msg_request);


    // Send multiple messages to the queue
    SendMessageBatchRequest send_batch_request = new SendMessageBatchRequest()
            .withQueueUrl(queueUrl)
            .withEntries(
                    new SendMessageBatchRequestEntry(
                            "msg_1", "Hello from message 1"),
                    new SendMessageBatchRequestEntry(
                            "msg_2", "Hello from message 2")
                            .withDelaySeconds(10));
    sqs.sendMessageBatch(send_batch_request);

    // receive messages from the queue
    List<Message> messages = sqs.receiveMessage(queueUrl).getMessages();

    // delete messages from the queue
    for (Message m : messages) {
        sqs.deleteMessage(queueUrl, m.getReceiptHandle());
    }
}
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:41,代码来源:SendReceiveMessages.java

示例12: 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);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:31,代码来源:SqsEndpoint.java

示例13: createQueue

import com.amazonaws.services.sqs.model.CreateQueueResult; //导入依赖的package包/类
@Override
public CreateQueueResult createQueue(CreateQueueRequest createQueueRequest) throws AmazonServiceException, AmazonClientException {
    String queueName = "https://queue.amazonaws.com/541925086079/" + createQueueRequest.getQueueName();
    queues.put(queueName, createQueueRequest);
    CreateQueueResult result = new CreateQueueResult();
    result.setQueueUrl(queueName);
    return result;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:AmazonSQSClientMock.java

示例14: 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);
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:12,代码来源:SQSTestBase.java

示例15: createQueue

import com.amazonaws.services.sqs.model.CreateQueueResult; //导入依赖的package包/类
@Override
public Queue createQueue(CreateQueueRequest request,
        ResultCapture<CreateQueueResult> extractor) {

    ActionResult result = service.performAction("CreateQueue", request,
            extractor);

    if (result == null) return null;
    return new QueueImpl(result.getResource());
}
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:11,代码来源:SQSImpl.java


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