com.amazonaws.services.sqs.model.ChangeMessageVisibilityRequest Java Examples
The following examples show how to use
com.amazonaws.services.sqs.model.ChangeMessageVisibilityRequest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QueueMessageVisibility.java From spring-cloud-aws with Apache License 2.0 | 5 votes |
@Override public Future<?> extend(int seconds) { return this.amazonSqsAsync .changeMessageVisibilityAsync(new ChangeMessageVisibilityRequest() .withQueueUrl(this.queueUrl).withReceiptHandle(this.receiptHandle) .withVisibilityTimeout(seconds)); }
Example #2
Source File: AmazonSQSMessagingClientWrapperTest.java From amazon-sqs-java-messaging-lib with Apache License 2.0 | 5 votes |
@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); }
Example #3
Source File: AmazonSQSMessagingClientWrapperTest.java From amazon-sqs-java-messaging-lib with Apache License 2.0 | 5 votes |
@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); }
Example #4
Source File: AmazonSQSMessagingClientWrapperTest.java From amazon-sqs-java-messaging-lib with Apache License 2.0 | 5 votes |
@Test public void testChangeMessageVisibility() throws JMSException { ChangeMessageVisibilityRequest changeMessageVisibilityRequest = new ChangeMessageVisibilityRequest(); wrapper.changeMessageVisibility(changeMessageVisibilityRequest); verify(amazonSQSClient).changeMessageVisibility(changeMessageVisibilityRequest); }
Example #5
Source File: MessageImpl.java From aws-sdk-java-resources with Apache License 2.0 | 5 votes |
@Override public void changeVisibility(Integer visibilityTimeout, ResultCapture<Void> extractor) { ChangeMessageVisibilityRequest request = new ChangeMessageVisibilityRequest() .withVisibilityTimeout(visibilityTimeout); changeVisibility(request, extractor); }
Example #6
Source File: AmazonSQSIdleQueueDeletingClient.java From amazon-sqs-java-temporary-queues-client with Apache License 2.0 | 5 votes |
@Override public ChangeMessageVisibilityResult changeMessageVisibility(ChangeMessageVisibilityRequest request) { // If the queue is deleted, there's no way to change the message visibility. try { return super.changeMessageVisibility(request); } catch (QueueDoesNotExistException|ReceiptHandleIsInvalidException e) { // Try on the alternate queue return super.changeMessageVisibility( request.clone().withQueueUrl(alternateQueueName(request.getQueueUrl()))); } }
Example #7
Source File: AmazonSQSExtendedClient.java From amazon-sqs-java-extended-client-lib with Apache License 2.0 | 5 votes |
/** * 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); }
Example #8
Source File: SqsTriggeredJobExecutor.java From soundwave with Apache License 2.0 | 5 votes |
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); }
Example #9
Source File: MockSQSQueue.java From amazon-sqs-java-temporary-queues-client with Apache License 2.0 | 5 votes |
public ChangeMessageVisibilityResult changeMessageVisibility(ChangeMessageVisibilityRequest request) { String receiptHandle = request.getReceiptHandle(); if (inflight.containsKey(receiptHandle)) { if (request.getVisibilityTimeout() == 0) { visibleMessages.add(inflight.remove(receiptHandle)); } else { // TODO-RS: Message timers } } else { // TODO-RS: Error? } return new ChangeMessageVisibilityResult(); }
Example #10
Source File: SQSObservableQueue.java From conductor with Apache License 2.0 | 4 votes |
@Override public void setUnackTimeout(Message message, long unackTimeout) { int unackTimeoutInSeconds = (int) (unackTimeout / 1000); ChangeMessageVisibilityRequest request = new ChangeMessageVisibilityRequest(queueURL, message.getReceipt(), unackTimeoutInSeconds); client.changeMessageVisibility(request); }
Example #11
Source File: SimpleMessageListenerContainerTest.java From spring-cloud-aws with Apache License 2.0 | 4 votes |
@Test void receiveMessage_withMessageListenerMethodAndVisibilityProlonging_callsChangeMessageVisibility() throws Exception { // Arrange CountDownLatch countDownLatch = new CountDownLatch(1); SimpleMessageListenerContainer container = new SimpleMessageListenerContainer() { @Override protected void executeMessage( org.springframework.messaging.Message<String> stringMessage) { countDownLatch.countDown(); super.executeMessage(stringMessage); } }; AmazonSQSAsync sqs = mock(AmazonSQSAsync.class); container.setAmazonSqs(sqs); QueueMessageHandler messageHandler = new QueueMessageHandler(); container.setMessageHandler(messageHandler); StaticApplicationContext applicationContext = new StaticApplicationContext(); applicationContext.registerSingleton("testListener", TestMessageListenerWithVisibilityProlong.class); mockGetQueueUrl(sqs, "testQueue", "https://receiveMessage_withMessageListenerMethodAnd" + "VisibilityProlonging_callsChangeMessageVisibility.amazonaws.com"); mockGetQueueAttributesWithEmptyResult(sqs, "https://receiveMessage_withMessageListenerMethodAnd" + "VisibilityProlonging_callsChangeMessageVisibility.amazonaws.com"); messageHandler.setApplicationContext(applicationContext); messageHandler.afterPropertiesSet(); container.afterPropertiesSet(); mockReceiveMessage(sqs, "https://receiveMessage_withMessageListenerMethodAnd" + "VisibilityProlonging_callsChangeMessageVisibility.amazonaws.com", "messageContent", "ReceiptHandle"); // Act container.start(); // Assert countDownLatch.await(1L, TimeUnit.SECONDS); verify(sqs, never()) .changeMessageVisibilityAsync(any(ChangeMessageVisibilityRequest.class)); TestMessageListenerWithVisibilityProlong testMessageListenerWithVisibilityProlong = applicationContext .getBean(TestMessageListenerWithVisibilityProlong.class); testMessageListenerWithVisibilityProlong.getCountDownLatch().await(1L, TimeUnit.SECONDS); testMessageListenerWithVisibilityProlong.extend(5); verify(sqs, times(1)) .changeMessageVisibilityAsync(eq(new ChangeMessageVisibilityRequest( "https://receiveMessage_withMessageListenerMethodAnd" + "VisibilityProlonging_callsChangeMessageVisibility.amazonaws.com", "ReceiptHandle", 5))); container.stop(); }
Example #12
Source File: MessageImpl.java From aws-sdk-java-resources with Apache License 2.0 | 4 votes |
@Override public void changeVisibility(ChangeMessageVisibilityRequest request) { changeVisibility(request, null); }
Example #13
Source File: MessageImpl.java From aws-sdk-java-resources with Apache License 2.0 | 4 votes |
@Override public void changeVisibility(ChangeMessageVisibilityRequest request, ResultCapture<Void> extractor) { resource.performAction("ChangeVisibility", request, extractor); }
Example #14
Source File: AbstractAmazonSQSClientWrapperTest.java From amazon-sqs-java-temporary-queues-client with Apache License 2.0 | 4 votes |
@Test public void changeMessageVisibility() { assertWrappedMethod(AmazonSQS::changeMessageVisibility, new ChangeMessageVisibilityRequest()); }
Example #15
Source File: MockSQS.java From amazon-sqs-java-temporary-queues-client with Apache License 2.0 | 4 votes |
@Override public ChangeMessageVisibilityResult changeMessageVisibility(ChangeMessageVisibilityRequest request) { return getQueue(request.getQueueUrl()).changeMessageVisibility(request); }
Example #16
Source File: AbstractAmazonSQSClientWrapper.java From amazon-sqs-java-temporary-queues-client with Apache License 2.0 | 4 votes |
@Override public ChangeMessageVisibilityResult changeMessageVisibility(ChangeMessageVisibilityRequest request) { request.getRequestClientOptions().appendUserAgent(userAgent); return amazonSqsToBeExtended.changeMessageVisibility(request); }
Example #17
Source File: AmazonSQSExtendedClient.java From amazon-sqs-java-extended-client-lib with Apache License 2.0 | 3 votes |
/** * <p> * Changes the visibility timeout of a specified message in a queue to a new * value. The maximum allowed timeout value you can set the value to is 12 * hours. This means you can't extend the timeout of a message in an * existing queue to more than a total visibility timeout of 12 hours. (For * more information visibility timeout, see <a href= * "http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/AboutVT.html" * > Visibility Timeout </a> in the <i>Amazon SQS Developer Guide</i> .) * </p> * <p> * For example, let's say you have a message and its default message * visibility timeout is 30 minutes. You could call * <code>ChangeMessageVisiblity</code> with a value of two hours and the * effective timeout would be two hours and 30 minutes. When that time comes * near you could again extend the time out by calling * ChangeMessageVisiblity, but this time the maximum allowed timeout would * be 9 hours and 30 minutes. * </p> * <p> * <b>NOTE:</b> There is a 120,000 limit for the number of inflight messages * per queue. Messages are inflight after they have been received from the * queue by a consuming component, but have not yet been deleted from the * queue. If you reach the 120,000 limit, you will receive an OverLimit * error message from Amazon SQS. To help avoid reaching the limit, you * should delete the messages from the queue after they have been processed. * You can also increase the number of queues you use to process the * messages. * </p> * <p> * <b>IMPORTANT:</b>If you attempt to set the VisibilityTimeout to an amount * more than the maximum time left, Amazon SQS returns an error. It will not * automatically recalculate and increase the timeout to the maximum time * remaining. * </p> * <p> * <b>IMPORTANT:</b>Unlike with a queue, when you change the visibility * timeout for a specific message, that timeout value is applied immediately * but is not saved in memory for that message. If you don't delete a * message after it is received, the visibility timeout for the message the * next time it is received reverts to the original timeout value, not the * value you set with the ChangeMessageVisibility action. * </p> * * @param changeMessageVisibilityRequest * Container for the necessary parameters to execute the * ChangeMessageVisibility service method on AmazonSQS. * * * @throws ReceiptHandleIsInvalidException * @throws MessageNotInflightException * * @throws AmazonClientException * If any internal errors are encountered inside the client * while attempting to make the request or handle the response. * For example if a network connection is not available. * @throws AmazonServiceException * If an error response is returned by AmazonSQS indicating * either a problem with the data in the request, or a server * side issue. */ public ChangeMessageVisibilityResult changeMessageVisibility(ChangeMessageVisibilityRequest changeMessageVisibilityRequest) throws AmazonServiceException, AmazonClientException { if (isS3ReceiptHandle(changeMessageVisibilityRequest.getReceiptHandle())) { changeMessageVisibilityRequest.setReceiptHandle( getOrigReceiptHandle(changeMessageVisibilityRequest.getReceiptHandle())); } return amazonSqsToBeExtended.changeMessageVisibility(changeMessageVisibilityRequest); }
Example #18
Source File: AmazonSQSMessagingClientWrapper.java From amazon-sqs-java-messaging-lib with Apache License 2.0 | 3 votes |
/** * Calls <code>changeMessageVisibility</code> and wraps <code>AmazonClientException</code>. This is * used to for negative acknowledge of a single message, so that messages can be received again without any delay. * * @param changeMessageVisibilityRequest * Container for the necessary parameters to execute the * changeMessageVisibility service method on AmazonSQS. * @throws JMSException */ public void changeMessageVisibility(ChangeMessageVisibilityRequest changeMessageVisibilityRequest) throws JMSException { try { prepareRequest(changeMessageVisibilityRequest); amazonSQSClient.changeMessageVisibility(changeMessageVisibilityRequest); } catch (AmazonClientException e) { throw handleException(e, "changeMessageVisibility"); } }
Example #19
Source File: AmazonSQSExtendedClientBase.java From amazon-sqs-java-extended-client-lib with Apache License 2.0 | 2 votes |
/** * <p> * Changes the visibility timeout of a specified message in a queue to a new * value. The maximum allowed timeout value you can set the value to is 12 * hours. This means you can't extend the timeout of a message in an * existing queue to more than a total visibility timeout of 12 hours. (For * more information visibility timeout, see <a href= * "http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/AboutVT.html" * > Visibility Timeout </a> in the <i>Amazon SQS Developer Guide</i> .) * </p> * <p> * For example, let's say you have a message and its default message * visibility timeout is 30 minutes. You could call * <code>ChangeMessageVisiblity</code> with a value of two hours and the * effective timeout would be two hours and 30 minutes. When that time comes * near you could again extend the time out by calling * ChangeMessageVisiblity, but this time the maximum allowed timeout would * be 9 hours and 30 minutes. * </p> * <p> * <b>NOTE:</b> There is a 120,000 limit for the number of inflight messages * per queue. Messages are inflight after they have been received from the * queue by a consuming component, but have not yet been deleted from the * queue. If you reach the 120,000 limit, you will receive an OverLimit * error message from Amazon SQS. To help avoid reaching the limit, you * should delete the messages from the queue after they have been processed. * You can also increase the number of queues you use to process the * messages. * </p> * <p> * <b>IMPORTANT:</b>If you attempt to set the VisibilityTimeout to an amount * more than the maximum time left, Amazon SQS returns an error. It will not * automatically recalculate and increase the timeout to the maximum time * remaining. * </p> * <p> * <b>IMPORTANT:</b>Unlike with a queue, when you change the visibility * timeout for a specific message, that timeout value is applied immediately * but is not saved in memory for that message. If you don't delete a * message after it is received, the visibility timeout for the message the * next time it is received reverts to the original timeout value, not the * value you set with the ChangeMessageVisibility action. * </p> * * @param changeMessageVisibilityRequest * Container for the necessary parameters to execute the * ChangeMessageVisibility service method on AmazonSQS. * * * @throws ReceiptHandleIsInvalidException * @throws MessageNotInflightException * * @throws AmazonClientException * If any internal errors are encountered inside the client * while attempting to make the request or handle the response. * For example if a network connection is not available. * @throws AmazonServiceException * If an error response is returned by AmazonSQS indicating * either a problem with the data in the request, or a server * side issue. */ public ChangeMessageVisibilityResult changeMessageVisibility(ChangeMessageVisibilityRequest changeMessageVisibilityRequest) throws AmazonServiceException, AmazonClientException { return amazonSqsToBeExtended.changeMessageVisibility(changeMessageVisibilityRequest); }
Example #20
Source File: Message.java From aws-sdk-java-resources with Apache License 2.0 | 2 votes |
/** * Performs the <code>ChangeVisibility</code> action. * * <p> * The following request parameters will be populated from the data of this * <code>Message</code> resource, and any conflicting parameter value set in * the request will be overridden: * <ul> * <li> * <b><code>QueueUrl</code></b> * - mapped from the <code>QueueUrl</code> identifier. * </li> * <li> * <b><code>ReceiptHandle</code></b> * - mapped from the <code>ReceiptHandle</code> identifier. * </li> * </ul> * * <p> * * @see ChangeMessageVisibilityRequest */ void changeVisibility(ChangeMessageVisibilityRequest request);
Example #21
Source File: Message.java From aws-sdk-java-resources with Apache License 2.0 | 2 votes |
/** * Performs the <code>ChangeVisibility</code> action and use a ResultCapture * to retrieve the low-level client response. * * <p> * The following request parameters will be populated from the data of this * <code>Message</code> resource, and any conflicting parameter value set in * the request will be overridden: * <ul> * <li> * <b><code>QueueUrl</code></b> * - mapped from the <code>QueueUrl</code> identifier. * </li> * <li> * <b><code>ReceiptHandle</code></b> * - mapped from the <code>ReceiptHandle</code> identifier. * </li> * </ul> * * <p> * * @see ChangeMessageVisibilityRequest */ void changeVisibility(ChangeMessageVisibilityRequest request, ResultCapture<Void> extractor);