本文整理汇总了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());
}
示例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));
}
示例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());
}
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
}
示例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);
}
示例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());
}
}
示例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);
}
示例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");
}
示例15: testChangeMessageVisibility_withEmptyRequestParams_shouldWork
import com.amazonaws.services.sqs.model.ChangeMessageVisibilityRequest; //导入依赖的package包/类
@Test
public void testChangeMessageVisibility_withEmptyRequestParams_shouldWork() {
assertNotNull(sqs.changeMessageVisibility(new ChangeMessageVisibilityRequest()));
}