use of com.amazonaws.services.sqs.model.DeleteMessageRequest in project thingsboard by thingsboard.
the class SqsDemoClient method pollMessages.
private void pollMessages(AmazonSQS sqs) {
log.info("Polling messages");
while (true) {
List<Message> messages = sqs.receiveMessage(QUEUE_URL).getMessages();
messages.forEach(m -> {
log.info("Message Received: " + m.getBody());
System.out.println(m.getBody());
DeleteMessageRequest deleteMessageRequest = new DeleteMessageRequest(QUEUE_URL, m.getReceiptHandle());
sqs.deleteMessage(deleteMessageRequest);
});
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
e.printStackTrace();
}
}
}
use of com.amazonaws.services.sqs.model.DeleteMessageRequest in project camel by apache.
the class SqsConsumer method processCommit.
/**
* Strategy to delete the message after being processed.
*
* @param exchange the exchange
*/
protected void processCommit(Exchange exchange) {
try {
if (shouldDelete(exchange)) {
String receiptHandle = exchange.getIn().getHeader(SqsConstants.RECEIPT_HANDLE, String.class);
DeleteMessageRequest deleteRequest = new DeleteMessageRequest(getQueueUrl(), receiptHandle);
LOG.trace("Deleting message with receipt handle {}...", receiptHandle);
getClient().deleteMessage(deleteRequest);
LOG.trace("Deleted message with receipt handle {}...", receiptHandle);
}
} catch (AmazonClientException e) {
getExceptionHandler().handleException("Error occurred during deleting message. This exception is ignored.", exchange, e);
}
}
Aggregations