本文整理汇总了Java中com.amazonaws.services.sqs.model.Message.getReceiptHandle方法的典型用法代码示例。如果您正苦于以下问题:Java Message.getReceiptHandle方法的具体用法?Java Message.getReceiptHandle怎么用?Java Message.getReceiptHandle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.sqs.model.Message
的用法示例。
在下文中一共展示了Message.getReceiptHandle方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMessages
import com.amazonaws.services.sqs.model.Message; //导入方法依赖的package包/类
public List<QueueMessage> getMessages() {
ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(_queueDns);
List<Message> messages = _sqs.receiveMessage(receiveMessageRequest).getMessages();
List<QueueMessage> deserializedMessages = new ArrayList<>();
for (Message message : messages) {
String body = message.getBody();
QueueMessage qm = _gson.fromJson(body, QueueMessage.class);
deserializedMessages.add(qm);
System.out.println("query time: " + qm.queryExecutionTime);
System.out.println("exec time: " + qm.totalExecutionTime);
System.out.println("Has ex: " + qm.hasException);
System.out.println("ex message: " + qm.exceptionMessage + "\n");
String receiptHandle = message.getReceiptHandle();
_sqs.deleteMessage(new DeleteMessageRequest(_queueDns, receiptHandle));
}
return deserializedMessages;
}
示例2: deleteMessage
import com.amazonaws.services.sqs.model.Message; //导入方法依赖的package包/类
private void deleteMessage(Message message) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Delete message " + message);
}
String messageReceiptHandle = message.getReceiptHandle();
sqs.deleteMessage(new DeleteMessageRequest(queueUrl, messageReceiptHandle));
}
示例3: remoteBatchReceive
import com.amazonaws.services.sqs.model.Message; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void remoteBatchReceive(PrintWriter out) throws ParseException{
JSONArray responseList = new JSONArray();
JSONParser parser=new JSONParser();
while(msg_cnt > 0){
while(resQ.getQueueSize() > 0){
//Get up to 10 messages
List<Message> messages = resQ.batchReceive();
for (Message message : messages) {
// System.out.println(" Message");
// System.out.println(" MessageId: " + message.getMessageId());
// System.out.println(" ReceiptHandle: " + message.getReceiptHandle());
// System.out.println(" MD5OfBody: " + message.getMD5OfBody());
// System.out.println(" Body: " + message.getBody());
//Get task
String messageBody = message.getBody();
JSONObject resp = (JSONObject)parser.parse(messageBody);
responseList.add(resp);
msg_cnt--;
// Delete the message
String messageRecieptHandle = message.getReceiptHandle();
resQ.deleteMessage(messageRecieptHandle);
}
if(!responseList.isEmpty()){
out.println(responseList.toString());
responseList.clear();
}
}
}
}
示例4: verifyReceiveEmail
import com.amazonaws.services.sqs.model.Message; //导入方法依赖的package包/类
private String verifyReceiveEmail(String expectedMessageId, String queueUrl, Integer visibilityTimeout) {
final ReceiveMessageResult receiveResult = _amazonSQS.receiveMessage(new ReceiveMessageRequest(queueUrl).withVisibilityTimeout(visibilityTimeout));
Assert.assertEquals(receiveResult.getMessages().size(), 1, "Expected one message");
final Message message = receiveResult.getMessages().get(0);
Assert.assertEquals(message.getMessageId(), expectedMessageId);
return message.getReceiptHandle();
}
示例5: doReceive
import com.amazonaws.services.sqs.model.Message; //导入方法依赖的package包/类
protected void doReceive() {
// This is where the interesting stuff happens
while (isListening()) {
synchronized (this.monitor) {
try {
this.monitor.wait(this.getVisibilityTimeout() * 1000);
} catch (InterruptedException e) {
}
}
boolean messagesReceived = false;
do {
ReceiveMessageRequest request = new ReceiveMessageRequest().withQueueUrl(this.queueUrl)
.withWaitTimeSeconds(1).withMaxNumberOfMessages(10);
ReceiveMessageResult result = sqs.receiveMessage(request);
List<Message> messages = result.getMessages();
messagesReceived = messages.size() > 0;
if (!messagesReceived) {
break;
}
List<DeleteMessageBatchRequestEntry> deletes = new ArrayList<DeleteMessageBatchRequestEntry>();
for (Message message : messages) {
String messageBody = message.getBody();
try {
this.messageConsumer.accept(messageBody);
DeleteMessageBatchRequestEntry entry = new DeleteMessageBatchRequestEntry(
UUID.randomUUID().toString(), message.getReceiptHandle());
deletes.add(entry);
} catch (Throwable exp) {
Logger.getLogger(getSqsQueueName()).log(Level.WARNING,
"Could not process message: " + messageBody, exp);
}
}
if (!deletes.isEmpty()) {
DeleteMessageBatchRequest deleteBatch = new DeleteMessageBatchRequest(this.queueUrl, deletes);
sqs.deleteMessageBatch(deleteBatch);
}
} while (messagesReceived);
}
}
示例6: toMessage
import com.amazonaws.services.sqs.model.Message; //导入方法依赖的package包/类
@Override
protected BasicMessage toMessage(final Message sqsMessage) {
return new SimpleBasicMessage(sqsMessage.getBody(), sqsMessage.getMessageId(), sqsMessage.getReceiptHandle());
}