本文整理了Java中com.amazonaws.services.sqs.model.ReceiveMessageRequest.withAttributeNames
方法的一些代码示例,展示了ReceiveMessageRequest.withAttributeNames
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ReceiveMessageRequest.withAttributeNames
方法的具体详情如下:
包路径:com.amazonaws.services.sqs.model.ReceiveMessageRequest
类名称:ReceiveMessageRequest
方法名:withAttributeNames
[英]A list of s that need to be returned along with each message. These attributes include:
All
- Returns all values.
ApproximateFirstReceiveTimestamp
- Returns the time the message was first received from the queue (epoch time in milliseconds).
ApproximateReceiveCount
- Returns the number of times a message has been received from the queue but not deleted.
SenderId
For an IAM user, returns the IAM user ID, for example ABCDEFGHI1JKLMNOPQ23R
.
ABCDE1F2GH3I4JK5LMNOP:i-a123b456
.SentTimestamp
- Returns the time the message was sent to the queue (epoch time in milliseconds).
MessageDeduplicationId
- Returns the value provided by the producer that calls the {{$2$}}
action.
MessageGroupId
- Returns the value provided by the producer that calls the {{$3$}}
action. Messages with the same MessageGroupId
are returned in sequence.
SequenceNumber
- Returns the value provided by Amazon SQS.
[中]需要随每条消息一起返回的消息列表。这些属性包括:
*All
-返回所有值。
*[$1$]-返回消息第一次从队列接收的时间(epoch time,以毫秒为单位)。
*ApproximateReceiveCount
-返回从队列收到但未删除的消息的次数。
SenderId
*对于IAM用户,返回IAM用户ID,例如[$4$]。
*对于IAM角色,返回IAM角色ID,例如ABCDE1F2GH3I4JK5LMNOP:i-a123b456
。
*[$6$]-返回消息发送到队列的时间(epoch time,以毫秒为单位)。
*MessageDeduplicationId
-返回调用{{$2$}}
操作的制作人提供的值。
*MessageGroupId
-返回调用{{$3$}}
操作的制作人提供的值。具有相同MessageGroupId
的邮件将按顺序返回。
*[$12$]-返回Amazon SQS提供的值。
代码示例来源:origin: skyscreamer/nevado
@Override
public AmazonAwsSQSMessage receiveMessage() throws JMSException {
AmazonAwsSQSMessage sqsMessage;
try {
ReceiveMessageRequest request = new ReceiveMessageRequest(_queueUrl)
.withAttributeNames(AmazonAwsSQSConnector.MESSAGE_ATTRIBUTE_APPROXIMATE_RECEIVE_COUNT);
ReceiveMessageResult result = _amazonAwsSQSConnector.getAmazonSQS().receiveMessage(request);
List<Message> messages = result.getMessages();
sqsMessage = (messages != null && messages.size() > 0) ? new AmazonAwsSQSMessage(messages.get(0)) : null;
} catch (AmazonClientException e) {
throw _amazonAwsSQSConnector.handleAWSException("Unable to retrieve message from queue " + _queueUrl, e);
}
return sqsMessage;
}
代码示例来源:origin: spring-cloud/spring-cloud-aws
@Override
public Message<String> receive(long timeout) {
ReceiveMessageResult receiveMessageResult = this.amazonSqs.receiveMessage(
new ReceiveMessageRequest(this.queueUrl).
withMaxNumberOfMessages(1).
withWaitTimeSeconds(Long.valueOf(timeout).intValue()).
withAttributeNames(ATTRIBUTE_NAMES).
withMessageAttributeNames(MESSAGE_ATTRIBUTE_NAMES));
if (receiveMessageResult.getMessages().isEmpty()) {
return null;
}
com.amazonaws.services.sqs.model.Message amazonMessage = receiveMessageResult.getMessages().get(0);
Message<String> message = createMessage(amazonMessage);
this.amazonSqs.deleteMessage(new DeleteMessageRequest(this.queueUrl, amazonMessage.getReceiptHandle()));
return message;
}
代码示例来源:origin: pinterest/soundwave
new ReceiveMessageRequest().withMaxNumberOfMessages(this.batchSize)
.withQueueUrl(queueUrl);
request.withAttributeNames("All");
代码示例来源:origin: org.springframework.cloud/spring-cloud-aws-messaging
@Override
public Message<String> receive(long timeout) {
ReceiveMessageResult receiveMessageResult = this.amazonSqs.receiveMessage(
new ReceiveMessageRequest(this.queueUrl).
withMaxNumberOfMessages(1).
withWaitTimeSeconds(Long.valueOf(timeout).intValue()).
withAttributeNames(ATTRIBUTE_NAMES).
withMessageAttributeNames(MESSAGE_ATTRIBUTE_NAMES));
if (receiveMessageResult.getMessages().isEmpty()) {
return null;
}
com.amazonaws.services.sqs.model.Message amazonMessage = receiveMessageResult.getMessages().get(0);
Message<String> message = createMessage(amazonMessage);
this.amazonSqs.deleteMessage(new DeleteMessageRequest(this.queueUrl, amazonMessage.getReceiptHandle()));
return message;
}
代码示例来源:origin: org.duracloud/common-queue
.withQueueUrl(queueUrl)
.withMaxNumberOfMessages(maxTasks)
.withAttributeNames("SentTimestamp", "ApproximateReceiveCount"));
if (result.getMessages() != null && result.getMessages().size() > 0) {
Set<Task> tasks = new HashSet<>();
代码示例来源:origin: awslabs/amazon-sqs-java-messaging-lib
.withAttributeNames(ALL)
.withMessageAttributeNames(ALL)
.withWaitTimeSeconds(WAIT_TIME_SECONDS);
代码示例来源:origin: spring-cloud/spring-cloud-aws
public ReceiveMessageRequest getReceiveMessageRequest() {
ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(this.destinationUrl).
withAttributeNames(RECEIVING_ATTRIBUTES).
withMessageAttributeNames(RECEIVING_MESSAGE_ATTRIBUTES);
if (this.maxNumberOfMessages != null) {
receiveMessageRequest.withMaxNumberOfMessages(this.maxNumberOfMessages);
} else {
receiveMessageRequest.withMaxNumberOfMessages(DEFAULT_MAX_NUMBER_OF_MESSAGES);
}
if (this.visibilityTimeout != null) {
receiveMessageRequest.withVisibilityTimeout(this.visibilityTimeout);
}
if (this.waitTimeOut != null) {
receiveMessageRequest.setWaitTimeSeconds(this.waitTimeOut);
}
return receiveMessageRequest;
}
代码示例来源:origin: org.springframework.cloud/spring-cloud-aws-messaging
public ReceiveMessageRequest getReceiveMessageRequest() {
ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(this.destinationUrl).
withAttributeNames(RECEIVING_ATTRIBUTES).
withMessageAttributeNames(RECEIVING_MESSAGE_ATTRIBUTES);
if (this.maxNumberOfMessages != null) {
receiveMessageRequest.withMaxNumberOfMessages(this.maxNumberOfMessages);
} else {
receiveMessageRequest.withMaxNumberOfMessages(DEFAULT_MAX_NUMBER_OF_MESSAGES);
}
if (this.visibilityTimeout != null) {
receiveMessageRequest.withVisibilityTimeout(this.visibilityTimeout);
}
if (this.waitTimeOut != null) {
receiveMessageRequest.setWaitTimeSeconds(this.waitTimeOut);
}
return receiveMessageRequest;
}
代码示例来源:origin: com.amazonaws/amazon-sqs-java-messaging-lib
.withAttributeNames(ALL)
.withMessageAttributeNames(ALL)
.withWaitTimeSeconds(WAIT_TIME_SECONDS);
代码示例来源:origin: aws/aws-cloudtrail-processing-library
/**
* Poll SQS queue for incoming messages, filter them, and return a list of SQS Messages.
*
* @return a list of SQS messages.
*/
public List<Message> pollQueue() {
boolean success = false;
ProgressStatus pollQueueStatus = new ProgressStatus(ProgressState.pollQueue, new BasicPollQueueInfo(0, success));
final Object reportObject = progressReporter.reportStart(pollQueueStatus);
ReceiveMessageRequest request = new ReceiveMessageRequest().withAttributeNames(ALL_ATTRIBUTES);
request.setQueueUrl(config.getSqsUrl());
request.setVisibilityTimeout(config.getVisibilityTimeout());
request.setMaxNumberOfMessages(DEFAULT_SQS_MESSAGE_SIZE_LIMIT);
request.setWaitTimeSeconds(DEFAULT_WAIT_TIME_SECONDS);
List<Message> sqsMessages = new ArrayList<Message>();
try {
ReceiveMessageResult result = sqsClient.receiveMessage(request);
sqsMessages = result.getMessages();
logger.info("Polled " + sqsMessages.size() + " sqs messages from " + config.getSqsUrl());
success = true;
} catch (AmazonServiceException e) {
LibraryUtils.handleException(exceptionHandler, pollQueueStatus, e, "Failed to poll sqs message.");
} finally {
LibraryUtils.endToProcess(progressReporter, success, pollQueueStatus, reportObject);
}
return sqsMessages;
}
代码示例来源:origin: spring-projects/spring-integration-aws
@Bean
public AmazonSQSAsync amazonSqs() {
AmazonSQSAsync sqs = mock(AmazonSQSAsync.class);
given(sqs.getQueueUrl(new GetQueueUrlRequest("testQueue")))
.willReturn(new GetQueueUrlResult().withQueueUrl("http://testQueue.amazonaws.com"));
given(sqs.receiveMessage(new ReceiveMessageRequest("http://testQueue.amazonaws.com")
.withAttributeNames("All")
.withMessageAttributeNames("All")
.withMaxNumberOfMessages(10)
.withWaitTimeSeconds(20)))
.willReturn(new ReceiveMessageResult()
.withMessages(new Message().withBody("messageContent"),
new Message().withBody("messageContent2")))
.willReturn(new ReceiveMessageResult());
given(sqs.getQueueAttributes(any(GetQueueAttributesRequest.class)))
.willReturn(new GetQueueAttributesResult());
return sqs;
}
内容来源于网络,如有侵权,请联系作者删除!