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


Java ChangeMessageVisibilityRequest类代码示例

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


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

示例1: testRun

import com.amazonaws.services.sqs.model.ChangeMessageVisibilityRequest; //导入依赖的package包/类
@Test
public void testRun() {
    // given

    // when
    uut.run();

    // then
    ArgumentCaptor<ChangeMessageVisibilityRequest> captor = ArgumentCaptor.forClass(
            ChangeMessageVisibilityRequest.class);
    verify(sqsClient).changeMessageVisibility(captor.capture());
    ChangeMessageVisibilityRequest request = captor.getValue();

    assertEquals("rhd", request.getReceiptHandle());
    assertEquals("queue", request.getQueueUrl());
    assertEquals(600, request.getVisibilityTimeout().intValue());
}
 
开发者ID:Mercateo,项目名称:sqs-utils,代码行数:18,代码来源:VisibilityTimeoutExtenderTest.java

示例2: VisibilityTimeoutExtender

import com.amazonaws.services.sqs.model.ChangeMessageVisibilityRequest; //导入依赖的package包/类
VisibilityTimeoutExtender(@NonNull AmazonSQS sqsClient, @NonNull Duration newVisibilityTimeout,
        @NonNull Message<?> message, @NonNull String queueUrl) {
    this.sqsClient = sqsClient;

    request = new ChangeMessageVisibilityRequest().withQueueUrl(queueUrl).withReceiptHandle(
            message.getHeaders().get("ReceiptHandle", String.class)).withVisibilityTimeout(
                    timeoutInSeconds(newVisibilityTimeout));
}
 
开发者ID:Mercateo,项目名称:sqs-utils,代码行数:9,代码来源:VisibilityTimeoutExtender.java

示例3: longReceiveExtendsMessageVisibility

import com.amazonaws.services.sqs.model.ChangeMessageVisibilityRequest; //导入依赖的package包/类
@Test
public void longReceiveExtendsMessageVisibility() throws Exception {
    this.mock.expectedMessageCount(1);
    this.mock.whenAnyExchangeReceived(new Processor() {
        @Override
        public void process(Exchange exchange) throws Exception {
            // Simulate message that takes a while to receive.
            Thread.sleep(TIMEOUT * 1500L); // 150% of TIMEOUT.
        }
    });

    Message message = new Message();
    message.setBody("Message 1");
    message.setMD5OfBody("6a1559560f67c5e7a7d5d838bf0272ee");
    message.setMessageId("f6fb6f99-5eb2-4be4-9b15-144774141458");
    message.setReceiptHandle(RECEIPT_HANDLE);
    this.clientMock.messages.add(message);

    assertMockEndpointsSatisfied(); // Wait for message to arrive.

    assertTrue("Expected at least one changeMessageVisibility request.", this.clientMock.changeMessageVisibilityRequests.size() >= 1);
    for (ChangeMessageVisibilityRequest req : this.clientMock.changeMessageVisibilityRequests) {
        assertEquals("https://queue.amazonaws.com/541925086079/MyQueue", req.getQueueUrl());
        assertEquals(RECEIPT_HANDLE, req.getReceiptHandle());
        Integer expectedTimeout = new Integer(6); // Should be 1.5 x TIMEOUT as takes into account the delay period
        assertEquals(expectedTimeout, req.getVisibilityTimeout());
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:29,代码来源:SqsExtendMessageVisibilityTest.java

示例4: changeMessageVisibility

import com.amazonaws.services.sqs.model.ChangeMessageVisibilityRequest; //导入依赖的package包/类
/**
 * Simplified method form for invoking the ChangeMessageVisibility
 * operation.
 *
 * @see #changeMessageVisibility(ChangeMessageVisibilityRequest)
 */
public ChangeMessageVisibilityResult changeMessageVisibility(String queueUrl,
                                                             String receiptHandle,
                                                             Integer visibilityTimeout) {
	ChangeMessageVisibilityRequest changeMessageVisibilityRequest =
			new ChangeMessageVisibilityRequest(queueUrl, receiptHandle, visibilityTimeout);
	return changeMessageVisibility(changeMessageVisibilityRequest);
}
 
开发者ID:awslabs,项目名称:amazon-sqs-java-extended-client-lib,代码行数:14,代码来源:AmazonSQSExtendedClient.java

示例5: changeVisibility

import com.amazonaws.services.sqs.model.ChangeMessageVisibilityRequest; //导入依赖的package包/类
@Override
public void changeVisibility(Integer visibilityTimeout, ResultCapture<Void>
        extractor) {

    ChangeMessageVisibilityRequest request = new
            ChangeMessageVisibilityRequest()

        .withVisibilityTimeout(visibilityTimeout);
    changeVisibility(request, extractor);
}
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:11,代码来源:MessageImpl.java

示例6: extend

import com.amazonaws.services.sqs.model.ChangeMessageVisibilityRequest; //导入依赖的package包/类
@Override
public Future<?> extend(int seconds) {
    return this.amazonSqsAsync.changeMessageVisibilityAsync(new ChangeMessageVisibilityRequest()
            .withQueueUrl(this.queueUrl)
            .withReceiptHandle(this.receiptHandle)
            .withVisibilityTimeout(seconds));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:8,代码来源:QueueMessageVisibility.java

示例7: testChangeMessageVisibility

import com.amazonaws.services.sqs.model.ChangeMessageVisibilityRequest; //导入依赖的package包/类
@Test
public void testChangeMessageVisibility() throws JMSException {

    ChangeMessageVisibilityRequest changeMessageVisibilityRequest = new ChangeMessageVisibilityRequest();
    wrapper.changeMessageVisibility(changeMessageVisibilityRequest);
    verify(amazonSQSClient).changeMessageVisibility(changeMessageVisibilityRequest);
}
 
开发者ID:awslabs,项目名称:amazon-sqs-java-messaging-lib,代码行数:8,代码来源:AmazonSQSMessagingClientWrapperTest.java

示例8: testChangeMessageVisibilityThrowAmazonClientException

import com.amazonaws.services.sqs.model.ChangeMessageVisibilityRequest; //导入依赖的package包/类
@Test(expected = JMSException.class)
public void testChangeMessageVisibilityThrowAmazonClientException() throws JMSException {

    ChangeMessageVisibilityRequest changeMessageVisibilityRequest = new ChangeMessageVisibilityRequest();
    doThrow(new AmazonClientException("ace"))
            .when(amazonSQSClient).changeMessageVisibility(eq(changeMessageVisibilityRequest));

    wrapper.changeMessageVisibility(changeMessageVisibilityRequest);
}
 
开发者ID:awslabs,项目名称:amazon-sqs-java-messaging-lib,代码行数:10,代码来源:AmazonSQSMessagingClientWrapperTest.java

示例9: testChangeMessageVisibilityThrowAmazonServiceException

import com.amazonaws.services.sqs.model.ChangeMessageVisibilityRequest; //导入依赖的package包/类
@Test(expected = JMSException.class)
public void testChangeMessageVisibilityThrowAmazonServiceException() throws JMSException {

    ChangeMessageVisibilityRequest changeMessageVisibilityRequest = new ChangeMessageVisibilityRequest();
    doThrow(new AmazonServiceException("ase"))
            .when(amazonSQSClient).changeMessageVisibility(eq(changeMessageVisibilityRequest));

    wrapper.changeMessageVisibility(changeMessageVisibilityRequest);
}
 
开发者ID:awslabs,项目名称:amazon-sqs-java-messaging-lib,代码行数:10,代码来源:AmazonSQSMessagingClientWrapperTest.java

示例10: changeMessageVisibility

import com.amazonaws.services.sqs.model.ChangeMessageVisibilityRequest; //导入依赖的package包/类
@Override
public ChangeMessageVisibilityResult changeMessageVisibility(ChangeMessageVisibilityRequest changeMessageVisibilityRequest) throws AmazonClientException {
    try {
        DirectorySQSQueue queue = getQueueFromUrl(changeMessageVisibilityRequest.getQueueUrl(), false);
        queue.changeVisibility(changeMessageVisibilityRequest.getReceiptHandle(), changeMessageVisibilityRequest.getVisibilityTimeout());
        return new ChangeMessageVisibilityResult();
    } catch (IOException e) {
        throw new AmazonServiceException("error", e);
    }
}
 
开发者ID:bazaarvoice,项目名称:awslocal,代码行数:11,代码来源:DirectorySQS.java

示例11: willReceiveMessageAfterTimeout

import com.amazonaws.services.sqs.model.ChangeMessageVisibilityRequest; //导入依赖的package包/类
public void willReceiveMessageAfterTimeout()
        throws InterruptedException {
    final String queueUrl = someNewQueue();

    final String messageBody = someMessageBody();

    final SendMessageResult sendResult = _amazonSQS.sendMessage(new SendMessageRequest(queueUrl, messageBody));
    Assert.assertNotNull(sendResult.getMD5OfMessageBody());

    verifyReceiveEmail(sendResult.getMessageId(), queueUrl, 1);
    sleep(1);

    verifyReceiveEmail(sendResult.getMessageId(), queueUrl, 2);
    sleep(1);

    verifyReceiveNone(queueUrl);
    sleep(1);

    final String receiptHandle = verifyReceiveEmail(sendResult.getMessageId(), queueUrl, 1);
    _amazonSQS.changeMessageVisibility(new ChangeMessageVisibilityRequest(queueUrl, receiptHandle, 3));
    sleep(2);

    verifyReceiveNone(queueUrl);
    sleep(1);

    verifyReceiveEmail(sendResult.getMessageId(), queueUrl, null);
}
 
开发者ID:bazaarvoice,项目名称:awslocal,代码行数:28,代码来源:TestSQSClient.java

示例12: setVisibilityTimeout

import com.amazonaws.services.sqs.model.ChangeMessageVisibilityRequest; //导入依赖的package包/类
@Override
public void setVisibilityTimeout(Message message, Integer visibilityTimeoutSeconds) {
    if (message instanceof OriginatingMessage) {
        OriginatingMessage originatingMessage = (OriginatingMessage) message;
        sqs.changeMessageVisibility(new ChangeMessageVisibilityRequest(originatingMessage.getOriginatingQueueUrl(), message.getReceipt(), visibilityTimeoutSeconds));
    } else {
        throw new RuntimeException("Unsupported message type: " + message.getBody());
    }
}
 
开发者ID:blacklocus,项目名称:queue-slayer,代码行数:10,代码来源:AmazonSQSPrioritizedMessageProvider.java

示例13: changeMessageVisibility

import com.amazonaws.services.sqs.model.ChangeMessageVisibilityRequest; //导入依赖的package包/类
public void changeMessageVisibility(Message msg, int value) {
  logger.info("Change visibility to {} seconds", value);
  if (value > 36000) {
    value = 36000;
  }
  ChangeMessageVisibilityRequest
      request =
      new ChangeMessageVisibilityRequest()
          .withQueueUrl(this.queueUrl)
          .withReceiptHandle(msg.getReceiptHandle()).withVisibilityTimeout(value);
  this.getClient().changeMessageVisibility(request);
}
 
开发者ID:pinterest,项目名称:soundwave,代码行数:13,代码来源:SqsTriggeredJobExecutor.java

示例14: testSendChangeVisibilityReceiveDeleteMessage_shouldSendChangeVisibilityReceiveAndDeleteMessage

import com.amazonaws.services.sqs.model.ChangeMessageVisibilityRequest; //导入依赖的package包/类
@Test
public void testSendChangeVisibilityReceiveDeleteMessage_shouldSendChangeVisibilityReceiveAndDeleteMessage() {
  // create queue
  CreateQueueResult createdQueue = sqs.createQueue(new CreateQueueRequest().withQueueName("tea-earl-grey-queue"));
  // send message
  String messageBody = "{\"life-universe-everything\":42}";
  SendMessageResult sendResult = sqs.sendMessage(new SendMessageRequest().withDelaySeconds(0).withMessageBody(messageBody)
      .withMessageGroupId("some-group-id-123").withQueueUrl(createdQueue.getQueueUrl()));
  assertNotNull("message sending returned ok", sendResult);
  assertNotNull("verify body MD5 exists",sendResult.getMD5OfMessageBody());
  assertNotNull("verify message id exists",sendResult.getMessageId());
  // receive message
  ReceiveMessageResult messageResult = sqs.receiveMessage(new ReceiveMessageRequest()
      .withMaxNumberOfMessages(3).withQueueUrl(createdQueue.getQueueUrl()).withVisibilityTimeout(10)
      .withWaitTimeSeconds(0));
  assertNotNull("verify received message returned ok",messageResult);
  assertEquals("verify correct receive count", 1, messageResult.getMessages().size());
  Message firstMessage = messageResult.getMessages().get(0);
  assertEquals("verify correct body returned",messageBody,firstMessage.getBody());
  assertEquals("verify correct message MD5",getAwsMessageMD5(messageBody),firstMessage.getMD5OfBody());
  assertNotNull("verify message id exists",firstMessage.getMessageId());
  assertNotNull("verify receipt handle exists",firstMessage.getReceiptHandle());
  
  // extend visibility timeout
  ChangeMessageVisibilityResult visibilityResult = sqs.changeMessageVisibility(new ChangeMessageVisibilityRequest()
      .withQueueUrl(createdQueue.getQueueUrl()).withReceiptHandle(firstMessage.getReceiptHandle()).withVisibilityTimeout(40));
  assertNotNull("changing visibility returned ok", visibilityResult);
  
  // verify if message is invisible
  ReceiveMessageResult emptyResult = sqs.receiveMessage(new ReceiveMessageRequest()
      .withMaxNumberOfMessages(1).withQueueUrl(createdQueue.getQueueUrl()).withVisibilityTimeout(20)
      .withWaitTimeSeconds(0));
  assertTrue("at visibility timeout the message should not be available.", emptyResult.getMessages().isEmpty());
  
  // delete message from queue
  DeleteMessageResult deleteResult = sqs.deleteMessage(new DeleteMessageRequest()
      .withQueueUrl(createdQueue.getQueueUrl()).withReceiptHandle(firstMessage.getReceiptHandle()));
  assertNotNull("verify deletion returned ok",deleteResult);

  assertTrue("queue must be empty after removal",getQueues().get("tea-earl-grey-queue").getMessageQueue().isEmpty());
  assertTrue("invisibility-queue must be empty after removal",getQueues().get("tea-earl-grey-queue").getInvisibilityQueueFor(firstMessage.getReceiptHandle()).isEmpty());
  
  // cleanup
  getQueues().remove("tea-earl-grey-queue");
}
 
开发者ID:daflockinger,项目名称:unitstack,代码行数:46,代码来源:MockSqsTest.java

示例15: testChangeMessageVisibility_withEmptyRequestParams_shouldWork

import com.amazonaws.services.sqs.model.ChangeMessageVisibilityRequest; //导入依赖的package包/类
@Test
public void testChangeMessageVisibility_withEmptyRequestParams_shouldWork() {
  assertNotNull(sqs.changeMessageVisibility(new ChangeMessageVisibilityRequest()));
}
 
开发者ID:daflockinger,项目名称:unitstack,代码行数:5,代码来源:MockSqsTest.java


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