List of usage examples for com.amazonaws.services.sqs.model ReceiveMessageRequest withVisibilityTimeout
public ReceiveMessageRequest withVisibilityTimeout(Integer visibilityTimeout)
The duration (in seconds) that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request.
From source file:org.springframework.cloud.aws.messaging.listener.AbstractMessageListenerContainer.java
License:Apache License
private QueueAttributes queueAttributes(String queue, SqsMessageDeletionPolicy deletionPolicy) { String destinationUrl;/*from w ww. j a va 2 s . c o m*/ try { destinationUrl = getDestinationResolver().resolveDestination(queue); } catch (DestinationResolutionException e) { getLogger().warn(String.format("The queue with name '%s' does not exist.", queue), e); return null; } ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(destinationUrl) .withAttributeNames(RECEIVING_ATTRIBUTES).withMessageAttributeNames(RECEIVING_MESSAGE_ATTRIBUTES); if (getMaxNumberOfMessages() != null) { receiveMessageRequest.withMaxNumberOfMessages(getMaxNumberOfMessages()); } else { receiveMessageRequest.withMaxNumberOfMessages(DEFAULT_MAX_NUMBER_OF_MESSAGES); } if (getVisibilityTimeout() != null) { receiveMessageRequest.withVisibilityTimeout(getVisibilityTimeout()); } if (getWaitTimeOut() != null) { receiveMessageRequest.setWaitTimeSeconds(getWaitTimeOut()); } GetQueueAttributesResult queueAttributes = getAmazonSqs().getQueueAttributes( new GetQueueAttributesRequest(destinationUrl).withAttributeNames(QueueAttributeName.RedrivePolicy)); boolean hasRedrivePolicy = queueAttributes.getAttributes() .containsKey(QueueAttributeName.RedrivePolicy.toString()); return new QueueAttributes(receiveMessageRequest, hasRedrivePolicy, deletionPolicy); }
From source file:support.SQS.java
License:Open Source License
public List<Message> receiveMessages() throws Exception { // Receive messages ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(receive_queue_url); receiveMessageRequest.withMessageAttributeNames(message_attribute_name); receiveMessageRequest.withAttributeNames(attribute_name); receiveMessageRequest.withWaitTimeSeconds(wait_time_seconds); receiveMessageRequest.withMaxNumberOfMessages(max_no_messages); receiveMessageRequest.withVisibilityTimeout(visibility_timeout); List<Message> messages = sqs.receiveMessage(receiveMessageRequest).getMessages(); return messages; }