com.amazonaws.services.sqs.model.DeleteMessageBatchRequest Java Examples
The following examples show how to use
com.amazonaws.services.sqs.model.DeleteMessageBatchRequest.
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: TestDeleteSQS.java From nifi with Apache License 2.0 | 6 votes |
@Test public void testDeleteException() { runner.setProperty(DeleteSQS.QUEUE_URL, "https://sqs.us-west-2.amazonaws.com/123456789012/test-queue-000000000"); final Map<String, String> ff1Attributes = new HashMap<>(); ff1Attributes.put("filename", "1.txt"); ff1Attributes.put("sqs.receipt.handle", "test-receipt-handle-1"); runner.enqueue("TestMessageBody1", ff1Attributes); Mockito.when(mockSQSClient.deleteMessageBatch(Mockito.any(DeleteMessageBatchRequest.class))) .thenThrow(new AmazonSQSException("TestFail")); runner.assertValid(); runner.run(1); ArgumentCaptor<DeleteMessageBatchRequest> captureDeleteRequest = ArgumentCaptor.forClass(DeleteMessageBatchRequest.class); Mockito.verify(mockSQSClient, Mockito.times(1)).deleteMessageBatch(captureDeleteRequest.capture()); runner.assertAllFlowFilesTransferred(DeleteSQS.REL_FAILURE, 1); }
Example #2
Source File: TestDeleteSQS.java From nifi with Apache License 2.0 | 6 votes |
@Test public void testDeleteWithCustomReceiptHandle() { runner.setProperty(DeleteSQS.QUEUE_URL, "https://sqs.us-west-2.amazonaws.com/123456789012/test-queue-000000000"); runner.setProperty(DeleteSQS.RECEIPT_HANDLE, "${custom.receipt.handle}"); final Map<String, String> ffAttributes = new HashMap<>(); ffAttributes.put("filename", "1.txt"); ffAttributes.put("custom.receipt.handle", "test-receipt-handle-1"); runner.enqueue("TestMessageBody", ffAttributes); runner.assertValid(); runner.run(1); ArgumentCaptor<DeleteMessageBatchRequest> captureDeleteRequest = ArgumentCaptor.forClass(DeleteMessageBatchRequest.class); Mockito.verify(mockSQSClient, Mockito.times(1)).deleteMessageBatch(captureDeleteRequest.capture()); DeleteMessageBatchRequest deleteRequest = captureDeleteRequest.getValue(); assertEquals("test-receipt-handle-1", deleteRequest.getEntries().get(0).getReceiptHandle()); runner.assertAllFlowFilesTransferred(DeleteSQS.REL_SUCCESS, 1); }
Example #3
Source File: TestDeleteSQS.java From nifi with Apache License 2.0 | 6 votes |
@Test public void testDeleteSingleMessage() { runner.setProperty(DeleteSQS.QUEUE_URL, "https://sqs.us-west-2.amazonaws.com/123456789012/test-queue-000000000"); final Map<String, String> ffAttributes = new HashMap<>(); ffAttributes.put("filename", "1.txt"); ffAttributes.put("sqs.receipt.handle", "test-receipt-handle-1"); runner.enqueue("TestMessageBody", ffAttributes); runner.assertValid(); runner.run(1); ArgumentCaptor<DeleteMessageBatchRequest> captureDeleteRequest = ArgumentCaptor.forClass(DeleteMessageBatchRequest.class); Mockito.verify(mockSQSClient, Mockito.times(1)).deleteMessageBatch(captureDeleteRequest.capture()); DeleteMessageBatchRequest deleteRequest = captureDeleteRequest.getValue(); assertEquals("https://sqs.us-west-2.amazonaws.com/123456789012/test-queue-000000000", deleteRequest.getQueueUrl()); assertEquals("test-receipt-handle-1", deleteRequest.getEntries().get(0).getReceiptHandle()); runner.assertAllFlowFilesTransferred(DeleteSQS.REL_SUCCESS, 1); }
Example #4
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 #5
Source File: SQSScanWorkflow.java From emodb with Apache License 2.0 | 6 votes |
@Override public void releaseCompleteScanRanges(Collection<ScanRangeComplete> completions) { if (completions.isEmpty()) { return; } int id = 0; List<DeleteMessageBatchRequestEntry> entries = Lists.newArrayListWithCapacity(completions.size()); for (ScanRangeComplete completion : completions) { entries.add( new DeleteMessageBatchRequestEntry() .withId(String.valueOf(id++)) .withReceiptHandle(((QueueScanRangeComplete) completion).getMessageId())); } _sqs.deleteMessageBatch(new DeleteMessageBatchRequest() .withQueueUrl(getQueueUrl(_completeScanRangeQueue)) .withEntries(entries)); }
Example #6
Source File: SQSResourcesIntegrationTest.java From aws-sdk-java-resources with Apache License 2.0 | 6 votes |
/** * Tests a simple send, receive and delete of a message from the queue * resource. Asserts the message contents and its associated attributes. */ @Test @Ignore public void testSendReceiveDelete() throws InterruptedException { SendMessageResult sendMessageResult = queue.sendMessage(TEST_MESSAGE); assertNotNull(sendMessageResult); assertNotNull(sendMessageResult.getMessageId()); List<Message> messages = waitForMessagesFromQueue(null); assertNotNull(messages); assertEquals(1, messages.size()); Message message = messages.get(0); assertMessage(TEST_MESSAGE, sendMessageResult.getMessageId(), sendMessageResult.getMD5OfMessageBody(), message); queue.deleteMessages(new DeleteMessageBatchRequest() .withEntries(new DeleteMessageBatchRequestEntry("msg1", message .getReceiptHandle()))); }
Example #7
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 #8
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 #9
Source File: AlertJanitor.java From s3mper with Apache License 2.0 | 5 votes |
private void delete(String queue, List<Message> messages) { List<DeleteMessageBatchRequestEntry> deleteRequests = new ArrayList<DeleteMessageBatchRequestEntry>(); for(Message m : messages) { deleteRequests.add(new DeleteMessageBatchRequestEntry().withId(m.getMessageId()).withReceiptHandle(m.getReceiptHandle())); } log.info(format("Deleting %s messages", deleteRequests.size())); DeleteMessageBatchRequest batchDelete = new DeleteMessageBatchRequest(); batchDelete.setQueueUrl(queue); batchDelete.setEntries(deleteRequests); sqs.deleteMessageBatch(batchDelete); }
Example #10
Source File: TestGetSQS.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testGetMessageAndAutoDelete() { runner.setProperty(GetSQS.QUEUE_URL, "https://sqs.us-west-2.amazonaws.com/123456789012/test-queue-000000000"); runner.setProperty(GetSQS.AUTO_DELETE, "true"); Message message1 = new Message(); message1.setBody("TestMessage1"); message1.setMessageId("test-message-id-1"); message1.setReceiptHandle("test-receipt-handle-1"); Message message2 = new Message(); message2.setBody("TestMessage2"); message2.setMessageId("test-message-id-2"); message2.setReceiptHandle("test-receipt-handle-2"); ReceiveMessageResult receiveMessageResult = new ReceiveMessageResult() .withMessages(message1, message2); Mockito.when(mockSQSClient.receiveMessage(Mockito.any(ReceiveMessageRequest.class))).thenReturn(receiveMessageResult); runner.run(1); ArgumentCaptor<ReceiveMessageRequest> captureReceiveRequest = ArgumentCaptor.forClass(ReceiveMessageRequest.class); Mockito.verify(mockSQSClient, Mockito.times(1)).receiveMessage(captureReceiveRequest.capture()); ReceiveMessageRequest receiveRequest = captureReceiveRequest.getValue(); assertEquals("https://sqs.us-west-2.amazonaws.com/123456789012/test-queue-000000000", receiveRequest.getQueueUrl()); ArgumentCaptor<DeleteMessageBatchRequest> captureDeleteRequest = ArgumentCaptor.forClass(DeleteMessageBatchRequest.class); Mockito.verify(mockSQSClient, Mockito.times(1)).deleteMessageBatch(captureDeleteRequest.capture()); DeleteMessageBatchRequest deleteRequest = captureDeleteRequest.getValue(); assertEquals("https://sqs.us-west-2.amazonaws.com/123456789012/test-queue-000000000", deleteRequest.getQueueUrl()); assertEquals("test-message-id-1", deleteRequest.getEntries().get(0).getId()); assertEquals("test-message-id-2", deleteRequest.getEntries().get(1).getId()); runner.assertAllFlowFilesTransferred(GetSQS.REL_SUCCESS, 2); List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(GetSQS.REL_SUCCESS); MockFlowFile ff0 = flowFiles.get(0); ff0.assertAttributeEquals("sqs.message.id", "test-message-id-1"); MockFlowFile ff1 = flowFiles.get(1); ff1.assertAttributeEquals("sqs.message.id", "test-message-id-2"); }
Example #11
Source File: TestGetSQS.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testGetMessageNoAutoDelete() { runner.setProperty(GetSQS.QUEUE_URL, "https://sqs.us-west-2.amazonaws.com/123456789012/test-queue-000000000"); runner.setProperty(GetSQS.AUTO_DELETE, "false"); Message message1 = new Message(); message1.setBody("TestMessage1"); message1.addAttributesEntry("attrib-key-1", "attrib-value-1"); MessageAttributeValue messageAttributeValue = new MessageAttributeValue(); messageAttributeValue.setStringValue("msg-attrib-value-1"); message1.addMessageAttributesEntry("msg-attrib-key-1", messageAttributeValue); message1.setMD5OfBody("test-md5-hash-1"); message1.setMessageId("test-message-id-1"); message1.setReceiptHandle("test-receipt-handle-1"); ReceiveMessageResult receiveMessageResult = new ReceiveMessageResult() .withMessages(message1); Mockito.when(mockSQSClient.receiveMessage(Mockito.any(ReceiveMessageRequest.class))).thenReturn(receiveMessageResult); runner.run(1); ArgumentCaptor<ReceiveMessageRequest> captureRequest = ArgumentCaptor.forClass(ReceiveMessageRequest.class); Mockito.verify(mockSQSClient, Mockito.times(1)).receiveMessage(captureRequest.capture()); ReceiveMessageRequest request = captureRequest.getValue(); assertEquals("https://sqs.us-west-2.amazonaws.com/123456789012/test-queue-000000000", request.getQueueUrl()); Mockito.verify(mockSQSClient, Mockito.never()).deleteMessageBatch(Mockito.any(DeleteMessageBatchRequest.class)); runner.assertAllFlowFilesTransferred(GetSQS.REL_SUCCESS, 1); List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(GetSQS.REL_SUCCESS); MockFlowFile ff0 = flowFiles.get(0); ff0.assertAttributeEquals("sqs.attrib-key-1", "attrib-value-1"); ff0.assertAttributeEquals("sqs.msg-attrib-key-1", "msg-attrib-value-1"); ff0.assertAttributeEquals("hash.value", "test-md5-hash-1"); ff0.assertAttributeEquals("hash.algorithm", "md5"); ff0.assertAttributeEquals("sqs.message.id", "test-message-id-1"); ff0.assertAttributeEquals("sqs.receipt.handle", "test-receipt-handle-1"); }
Example #12
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 #13
Source File: AmazonSQSMessagingClientWrapperTest.java From amazon-sqs-java-messaging-lib with Apache License 2.0 | 5 votes |
@Test(expected = JMSException.class) public void testDeleteMessageBatchThrowAmazonServiceException() throws JMSException { DeleteMessageBatchRequest deleteMessageBatchRequest = new DeleteMessageBatchRequest(); doThrow(new AmazonServiceException("ase")) .when(amazonSQSClient).deleteMessageBatch(eq(deleteMessageBatchRequest)); wrapper.deleteMessageBatch(deleteMessageBatchRequest); }
Example #14
Source File: AmazonSQSMessagingClientWrapperTest.java From amazon-sqs-java-messaging-lib with Apache License 2.0 | 5 votes |
@Test(expected = JMSException.class) public void testDeleteMessageBatchThrowAmazonClientException() throws JMSException { DeleteMessageBatchRequest deleteMessageBatchRequest = new DeleteMessageBatchRequest(); doThrow(new AmazonClientException("ace")) .when(amazonSQSClient).deleteMessageBatch(eq(deleteMessageBatchRequest)); wrapper.deleteMessageBatch(deleteMessageBatchRequest); }
Example #15
Source File: RangedAcknowledger.java From amazon-sqs-java-messaging-lib with Apache License 2.0 | 5 votes |
/** * Acknowledges up to 10 messages via calling * <code>deleteMessageBatch</code>. */ @Override public void action(String queueUrl, List<String> receiptHandles) throws JMSException { if (receiptHandles == null || receiptHandles.isEmpty()) { return; } List<DeleteMessageBatchRequestEntry> deleteMessageBatchRequestEntries = new ArrayList<DeleteMessageBatchRequestEntry>(); int batchId = 0; for (String receiptHandle : receiptHandles) { // Remove the message from queue of unAckMessages unAckMessages.poll(); DeleteMessageBatchRequestEntry entry = new DeleteMessageBatchRequestEntry( Integer.toString(batchId), receiptHandle); deleteMessageBatchRequestEntries.add(entry); batchId++; } 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); }
Example #16
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 #17
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 #18
Source File: RequestFactoryImpl.java From aws-codecommit-trigger-plugin with Apache License 2.0 | 5 votes |
@Override public DeleteMessageBatchRequest createDeleteMessageBatchRequest(String queueUrl, List<Message> messages) { final List<DeleteMessageBatchRequestEntry> entries = new ArrayList<>(messages.size()); for (final Message message : messages) { final DeleteMessageBatchRequestEntry entry = this.createDeleteMessageBatchRequestEntry(message); entries.add(entry); } final DeleteMessageBatchRequest request = new DeleteMessageBatchRequest(queueUrl); request.setEntries(entries); return request; }
Example #19
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 #20
Source File: AbstractAmazonSQSClientWrapperTest.java From amazon-sqs-java-temporary-queues-client with Apache License 2.0 | 4 votes |
@Test public void deleteMessageBatch() { assertWrappedMethod(AmazonSQS::deleteMessageBatch, new DeleteMessageBatchRequest()); }
Example #21
Source File: RequestFactoryImpl.java From aws-codecommit-trigger-plugin with Apache License 2.0 | 4 votes |
@Override public DeleteMessageBatchRequest createDeleteMessageBatchRequest(final SQSQueue queue, final List<Message> messages) { return createDeleteMessageBatchRequest(queue.getUrl(), messages); }
Example #22
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 #23
Source File: RangedAcknowledgerTest.java From amazon-sqs-java-messaging-lib with Apache License 2.0 | 4 votes |
/** * Test acknowledge 25 first un-acknowledge messages */ @Test public void testOneAck() throws JMSException { int populateMessageSize = 34; populateMessage(populateMessageSize); int ackMessage = 25; testAcknowledge(populateMessageSize, ackMessage); ArgumentCaptor<DeleteMessageBatchRequest> argumentCaptor = ArgumentCaptor.forClass(DeleteMessageBatchRequest.class); verify(amazonSQSClient, times(5)).deleteMessageBatch(argumentCaptor.capture()); //key is the queue url //value is the sequence of sizes of expected batches Map<String, List<Integer>> expectedCalls = new HashMap<String, List<Integer>>(); List<Integer> queue0Calls = new ArrayList<Integer>(); queue0Calls.add(10); queue0Calls.add(1); expectedCalls.put(baseQueueUrl + 0, queue0Calls); List<Integer> queue1Calls = new ArrayList<Integer>(); queue1Calls.add(10); queue1Calls.add(1); expectedCalls.put(baseQueueUrl + 1, queue1Calls); List<Integer> queue2Calls = new ArrayList<Integer>(); queue2Calls.add(4); expectedCalls.put(baseQueueUrl + 2, queue2Calls); for (DeleteMessageBatchRequest request : argumentCaptor.getAllValues()) { String queueUrl = request.getQueueUrl(); List<Integer> expectedSequence = expectedCalls.get(queueUrl); assertNotNull(expectedSequence); assertTrue(expectedSequence.size() > 0); assertEquals(expectedSequence.get(0).intValue(), request.getEntries().size()); expectedSequence.remove(0); if (expectedSequence.isEmpty()) { expectedCalls.remove(queueUrl); } } assertTrue(expectedCalls.isEmpty()); }
Example #24
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 #25
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 #26
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 #27
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 #28
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 #29
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 #30
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);