本文整理匯總了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());
}