com.amazonaws.services.sqs.model.DeleteMessageBatchResult Java Examples
The following examples show how to use
com.amazonaws.services.sqs.model.DeleteMessageBatchResult.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SQSObservableQueue.java From conductor with Apache License 2.0 | 6 votes |
private List<String> delete(List<Message> messages) { if (messages == null || messages.isEmpty()) { return null; } DeleteMessageBatchRequest batch = new DeleteMessageBatchRequest().withQueueUrl(queueURL); List<DeleteMessageBatchRequestEntry> entries = batch.getEntries(); messages.forEach(m -> entries.add(new DeleteMessageBatchRequestEntry().withId(m.getId()).withReceiptHandle(m.getReceipt()))); DeleteMessageBatchResult result = client.deleteMessageBatch(batch); List<String> failures = result.getFailed().stream() .map(BatchResultErrorEntry::getId) .collect(Collectors.toList()); logger.debug("Failed to delete messages from queue: {}: {}", queueName, failures); return failures; }
Example #2
Source File: AmazonSQSIdleQueueDeletingClient.java From amazon-sqs-java-temporary-queues-client with Apache License 2.0 | 6 votes |
@Override public DeleteMessageBatchResult deleteMessageBatch(DeleteMessageBatchRequest request) { String queueUrl = request.getQueueUrl(); try { heartbeatToQueueIfNecessary(queueUrl); return super.deleteMessageBatch(request); } catch (QueueDoesNotExistException e) { try { return super.deleteMessageBatch( request.clone().withQueueUrl(alternateQueueName(request.getQueueUrl()))); } catch (QueueDoesNotExistException e2) { // Silently fail - the message is definitely deleted after all! return new DeleteMessageBatchResult(); } } }
Example #3
Source File: QueueImpl.java From aws-sdk-java-resources with Apache License 2.0 | 5 votes |
@Override public DeleteMessageBatchResult deleteMessages( ResultCapture<DeleteMessageBatchResult> extractor) { DeleteMessageBatchRequest request = new DeleteMessageBatchRequest(); return deleteMessages(request, extractor); }
Example #4
Source File: TestDeleteSQS.java From nifi with Apache License 2.0 | 5 votes |
@Before public void setUp() { mockSQSClient = Mockito.mock(AmazonSQSClient.class); DeleteMessageBatchResult mockResponse = Mockito.mock(DeleteMessageBatchResult.class); Mockito.when(mockSQSClient.deleteMessageBatch(Mockito.any())).thenReturn(mockResponse); Mockito.when(mockResponse.getFailed()).thenReturn(new ArrayList<>()); mockDeleteSQS = new DeleteSQS() { @Override protected AmazonSQSClient getClient() { return mockSQSClient; } }; runner = TestRunners.newTestRunner(mockDeleteSQS); }
Example #5
Source File: DeleteSQS.java From nifi with Apache License 2.0 | 5 votes |
@Override public void onTrigger(final ProcessContext context, final ProcessSession session) { FlowFile flowFile = session.get(); if (flowFile == null) { return; } final String queueUrl = context.getProperty(QUEUE_URL).evaluateAttributeExpressions(flowFile).getValue(); final AmazonSQSClient client = getClient(); final DeleteMessageBatchRequest request = new DeleteMessageBatchRequest(); request.setQueueUrl(queueUrl); final List<DeleteMessageBatchRequestEntry> entries = new ArrayList<>(); final DeleteMessageBatchRequestEntry entry = new DeleteMessageBatchRequestEntry(); String receiptHandle = context.getProperty(RECEIPT_HANDLE).evaluateAttributeExpressions(flowFile).getValue(); entry.setReceiptHandle(receiptHandle); String entryId = flowFile.getAttribute(CoreAttributes.UUID.key()); entry.setId(entryId); entries.add(entry); request.setEntries(entries); try { DeleteMessageBatchResult response = client.deleteMessageBatch(request); // check for errors if (!response.getFailed().isEmpty()) { throw new ProcessException(response.getFailed().get(0).toString()); } getLogger().info("Successfully deleted message from SQS for {}", new Object[] { flowFile }); session.transfer(flowFile, REL_SUCCESS); } catch (final Exception e) { getLogger().error("Failed to delete message from SQS due to {}", new Object[] { e }); flowFile = session.penalize(flowFile); session.transfer(flowFile, REL_FAILURE); return; } }
Example #6
Source File: QueueImpl.java From aws-sdk-java-resources with Apache License 2.0 | 5 votes |
@Override public DeleteMessageBatchResult deleteMessages( List<DeleteMessageBatchRequestEntry> entries, ResultCapture<DeleteMessageBatchResult> extractor) { DeleteMessageBatchRequest request = new DeleteMessageBatchRequest() .withEntries(entries); return deleteMessages(request, extractor); }
Example #7
Source File: QueueImpl.java From aws-sdk-java-resources with Apache License 2.0 | 5 votes |
@Override public DeleteMessageBatchResult deleteMessages( List<DeleteMessageBatchRequestEntry> entries) { return deleteMessages(entries, (ResultCapture<DeleteMessageBatchResult>)null); }
Example #8
Source File: QueueImpl.java From aws-sdk-java-resources with Apache License 2.0 | 5 votes |
@Override public DeleteMessageBatchResult deleteMessages(DeleteMessageBatchRequest request, ResultCapture<DeleteMessageBatchResult> extractor) { ActionResult result = resource.performAction("DeleteMessages", request, extractor); if (result == null) return null; return (DeleteMessageBatchResult) result.getData(); }
Example #9
Source File: QueueImpl.java From aws-sdk-java-resources with Apache License 2.0 | 4 votes |
@Override public DeleteMessageBatchResult deleteMessages(DeleteMessageBatchRequest request) { return deleteMessages(request, null); }
Example #10
Source File: QueueImpl.java From aws-sdk-java-resources with Apache License 2.0 | 4 votes |
@Override public DeleteMessageBatchResult deleteMessages() { return deleteMessages((ResultCapture<DeleteMessageBatchResult>)null); }
Example #11
Source File: SqsConsumerWorkerCallable.java From datacollector with Apache License 2.0 | 4 votes |
private void sendDeleteMessageBatchRequest( String queueUrl, List<DeleteMessageBatchRequestEntry> deleteRequestEntries ) throws InterruptedException { DeleteMessageBatchRequest deleteRequest = new DeleteMessageBatchRequest() .withQueueUrl(queueUrl) .withEntries(deleteRequestEntries); Future<DeleteMessageBatchResult> deleteResultFuture = sqsAsync.deleteMessageBatchAsync(deleteRequest); try { DeleteMessageBatchResult deleteResult = deleteResultFuture.get(); if (deleteResult.getFailed() != null) { deleteResult.getFailed().forEach(failed -> LOG.error( "Failed to delete message ID {} from queue {} with code {}, sender fault {}", failed.getId(), queueUrl, failed.getCode(), failed.getSenderFault() )); } if (LOG.isDebugEnabled()) { if (deleteResult.getSuccessful() != null) { deleteResult.getSuccessful().forEach(success -> LOG.debug( "Successfully deleted message ID {} from queue {}", success.getId(), queueUrl )); } } } catch (ExecutionException e) { String messageIds = getPendingDeleteMessageIds(queueUrl); LOG.error( Errors.SQS_08.getMessage(), messageIds, queueUrl, e.getMessage(), e ); throw new StageException( Errors.SQS_08, messageIds, queueUrl, e.getMessage(), e ); } }
Example #12
Source File: SQSSpanProcessor.java From zipkin-aws with Apache License 2.0 | 4 votes |
private DeleteMessageBatchResult delete(List<DeleteMessageBatchRequestEntry> entries) { return client.deleteMessageBatch(queueUrl, entries); }
Example #13
Source File: AbstractAmazonSQSClientWrapper.java From amazon-sqs-java-temporary-queues-client with Apache License 2.0 | 4 votes |
@Override public DeleteMessageBatchResult deleteMessageBatch(DeleteMessageBatchRequest request) { request.getRequestClientOptions().appendUserAgent(userAgent); return amazonSqsToBeExtended.deleteMessageBatch(request); }
Example #14
Source File: AmazonSQSExtendedClient.java From amazon-sqs-java-extended-client-lib with Apache License 2.0 | 3 votes |
/** * <p> * 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 deleteMessageBatchRequest * Container for the necessary parameters to execute the * DeleteMessageBatch service method on AmazonSQS. * * @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(DeleteMessageBatchRequest deleteMessageBatchRequest) { if (deleteMessageBatchRequest == null) { String errorMessage = "deleteMessageBatchRequest cannot be null."; LOG.error(errorMessage); throw new AmazonClientException(errorMessage); } deleteMessageBatchRequest.getRequestClientOptions().appendUserAgent( SQSExtendedClientConstants.USER_AGENT_HEADER); if (!clientConfiguration.isLargePayloadSupportEnabled()) { return super.deleteMessageBatch(deleteMessageBatchRequest); } for (DeleteMessageBatchRequestEntry entry : deleteMessageBatchRequest.getEntries()) { String receiptHandle = entry.getReceiptHandle(); String origReceiptHandle = receiptHandle; if (isS3ReceiptHandle(receiptHandle)) { deleteMessagePayloadFromS3(receiptHandle); origReceiptHandle = getOrigReceiptHandle(receiptHandle); } entry.setReceiptHandle(origReceiptHandle); } return super.deleteMessageBatch(deleteMessageBatchRequest); }
Example #15
Source File: AmazonSQSMessagingClientWrapper.java From amazon-sqs-java-messaging-lib with Apache License 2.0 | 3 votes |
/** * Calls <code>deleteMessageBatch</code> and wraps * <code>AmazonClientException</code>. This is used to acknowledge multiple * messages on client_acknowledge mode, so that they can be deleted from SQS * queue. * * @param deleteMessageBatchRequest * Container for the necessary parameters to execute the * deleteMessageBatch service method on AmazonSQS. This is the * batch version of deleteMessage. Max batch size is 10. * @return The response from the deleteMessageBatch service method, as * returned by AmazonSQS * @throws JMSException */ public DeleteMessageBatchResult deleteMessageBatch(DeleteMessageBatchRequest deleteMessageBatchRequest) throws JMSException { try { prepareRequest(deleteMessageBatchRequest); return amazonSQSClient.deleteMessageBatch(deleteMessageBatchRequest); } catch (AmazonClientException e) { throw handleException(e, "deleteMessageBatch"); } }
Example #16
Source File: AmazonSQSExtendedClient.java From amazon-sqs-java-extended-client-lib with Apache License 2.0 | 2 votes |
/** * <p> * 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); }
Example #17
Source File: AmazonSQSExtendedClientBase.java From amazon-sqs-java-extended-client-lib with Apache License 2.0 | 2 votes |
/** * <p> * 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. * </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) throws AmazonServiceException, AmazonClientException { return amazonSqsToBeExtended.deleteMessageBatch(queueUrl, entries); }
Example #18
Source File: AmazonSQSExtendedClientBase.java From amazon-sqs-java-extended-client-lib with Apache License 2.0 | 2 votes |
/** * <p> * 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. * </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 deleteMessageBatchRequest * Container for the necessary parameters to execute the * DeleteMessageBatch service method on AmazonSQS. * * @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(DeleteMessageBatchRequest deleteMessageBatchRequest) throws AmazonServiceException, AmazonClientException { return amazonSqsToBeExtended.deleteMessageBatch(deleteMessageBatchRequest); }
Example #19
Source File: Queue.java From aws-sdk-java-resources with Apache License 2.0 | 2 votes |
/** * Performs the <code>DeleteMessages</code> action. * * <p> * The following request parameters will be populated from the data of this * <code>Queue</code> resource, and any conflicting parameter value set in * the request will be overridden: * <ul> * <li> * <b><code>QueueUrl</code></b> * - mapped from the <code>Url</code> identifier. * </li> * </ul> * * <p> * * @return The response of the low-level client operation associated with * this resource action. * @see DeleteMessageBatchRequest */ DeleteMessageBatchResult deleteMessages(DeleteMessageBatchRequest request);
Example #20
Source File: Queue.java From aws-sdk-java-resources with Apache License 2.0 | 2 votes |
/** * Performs the <code>DeleteMessages</code> action and use a ResultCapture * to retrieve the low-level client response. * * <p> * The following request parameters will be populated from the data of this * <code>Queue</code> resource, and any conflicting parameter value set in * the request will be overridden: * <ul> * <li> * <b><code>QueueUrl</code></b> * - mapped from the <code>Url</code> identifier. * </li> * </ul> * * <p> * * @return The response of the low-level client operation associated with * this resource action. * @see DeleteMessageBatchRequest */ DeleteMessageBatchResult deleteMessages(DeleteMessageBatchRequest request, ResultCapture<DeleteMessageBatchResult> extractor);
Example #21
Source File: Queue.java From aws-sdk-java-resources with Apache License 2.0 | 2 votes |
/** * The convenient method form for the <code>DeleteMessages</code> action. * * @see #deleteMessages(DeleteMessageBatchRequest) */ DeleteMessageBatchResult deleteMessages();
Example #22
Source File: Queue.java From aws-sdk-java-resources with Apache License 2.0 | 2 votes |
/** * The convenient method form for the <code>DeleteMessages</code> action. * * @see #deleteMessages(DeleteMessageBatchRequest, ResultCapture) */ DeleteMessageBatchResult deleteMessages( ResultCapture<DeleteMessageBatchResult> extractor);
Example #23
Source File: Queue.java From aws-sdk-java-resources with Apache License 2.0 | 2 votes |
/** * The convenient method form for the <code>DeleteMessages</code> action. * * @see #deleteMessages(DeleteMessageBatchRequest) */ DeleteMessageBatchResult deleteMessages(List<DeleteMessageBatchRequestEntry> entries);
Example #24
Source File: Queue.java From aws-sdk-java-resources with Apache License 2.0 | 2 votes |
/** * The convenient method form for the <code>DeleteMessages</code> action. * * @see #deleteMessages(DeleteMessageBatchRequest, ResultCapture) */ DeleteMessageBatchResult deleteMessages(List<DeleteMessageBatchRequestEntry> entries, ResultCapture<DeleteMessageBatchResult> extractor);