List of usage examples for com.amazonaws.services.sqs.model DeleteMessageBatchRequest DeleteMessageBatchRequest
public DeleteMessageBatchRequest(String queueUrl, java.util.List<DeleteMessageBatchRequestEntry> entries)
From source file:com.amazon.sqs.javamessaging.acknowledge.RangedAcknowledger.java
License:Open Source License
/** * Acknowledges up to 10 messages via calling * <code>deleteMessageBatch</code>. *///from w ww. j av a 2 s . c om @Override public void action(String queueUrl, List<String> receiptHandles) throws JMSException { if (receiptHandles == null || receiptHandles.isEmpty()) { return; } List<DeleteMessageBatchRequestEntry> deleteMessageBatchRequestEntries = new ArrayList<DeleteMessageBatchRequestEntry>(); for (String receiptHandle : receiptHandles) { // Remove the message from queue of unAckMessages unAckMessages.poll(); DeleteMessageBatchRequestEntry entry = new DeleteMessageBatchRequestEntry( Long.toString(batchIdGenerator.incrementAndGet()), receiptHandle); deleteMessageBatchRequestEntries.add(entry); } DeleteMessageBatchRequest deleteMessageBatchRequest = new DeleteMessageBatchRequest(queueUrl, deleteMessageBatchRequestEntries); /** * TODO: If one of the batch calls fail, then the remaining messages on * the batch will not be deleted, and will be visible and delivered as * duplicate after visibility timeout expires. */ amazonSQSClient.deleteMessageBatch(deleteMessageBatchRequest); }
From source file:com.amazon.sqs.javamessaging.AmazonSQSExtendedClient.java
License:Open Source License
/** * <p>/*from w w w . java2 s . co m*/ * Deletes up to ten messages from the specified queue. This is a batch * version of DeleteMessage. The result of the delete action on each message * is reported individually in the response. Also deletes the message * payloads from Amazon S3 when necessary. * </p> * <p> * <b>IMPORTANT:</b> Because the batch request can result in a combination * of successful and unsuccessful actions, you should check for batch errors * even when the call returns an HTTP status code of 200. * </p> * <p> * <b>NOTE:</b>Some API actions take lists of parameters. These lists are * specified using the param.n notation. Values of n are integers starting * from 1. For example, a parameter list with two elements looks like this: * </p> * <p> * <code>&Attribute.1=this</code> * </p> * <p> * <code>&Attribute.2=that</code> * </p> * * @param queueUrl * The URL of the Amazon SQS queue to take action on. * @param entries * A list of receipt handles for the messages to be deleted. * * @return The response from the DeleteMessageBatch service method, as * returned by AmazonSQS. * * @throws BatchEntryIdsNotDistinctException * @throws TooManyEntriesInBatchRequestException * @throws InvalidBatchEntryIdException * @throws EmptyBatchRequestException * * @throws AmazonClientException * If any internal errors are encountered inside the client * while attempting to make the request or handle the response. * For example if a network connection is not available. * @throws AmazonServiceException * If an error response is returned by AmazonSQS indicating * either a problem with the data in the request, or a server * side issue. */ public DeleteMessageBatchResult deleteMessageBatch(String queueUrl, List<DeleteMessageBatchRequestEntry> entries) { DeleteMessageBatchRequest deleteMessageBatchRequest = new DeleteMessageBatchRequest(queueUrl, entries); return deleteMessageBatch(deleteMessageBatchRequest); }
From source file:org.apache.usergrid.persistence.queue.impl.SNSQueueManagerImpl.java
License:Apache License
@Override public void commitMessages(final List<LegacyQueueMessage> queueMessages) { String url = getReadQueue().getUrl(); if (logger.isTraceEnabled()) { logger.trace("Commit messages {} to queue {}", queueMessages.size(), url); }/*www .ja va 2s . c o m*/ List<DeleteMessageBatchRequestEntry> entries = new ArrayList<>(); for (LegacyQueueMessage message : queueMessages) { entries.add(new DeleteMessageBatchRequestEntry(message.getMessageId(), message.getHandle())); } DeleteMessageBatchRequest request = new DeleteMessageBatchRequest(url, entries); DeleteMessageBatchResult result = sqs.deleteMessageBatch(request); boolean successful = result.getFailed().size() <= 0; if (!successful) { for (BatchResultErrorEntry failed : result.getFailed()) { logger.error("Commit failed reason: {} messages id: {}", failed.getMessage(), failed.getId()); } } }
From source file:smartthings.brave.sqs.TracingAmazonSQSClient.java
License:Apache License
@Override public DeleteMessageBatchResult deleteMessageBatch(String queueUrl, List<DeleteMessageBatchRequestEntry> entries) { return this.deleteMessageBatch(new DeleteMessageBatchRequest(queueUrl, entries)); }