当前位置: 首页>>代码示例>>Java>>正文


Java DeleteMessageBatchRequest类代码示例

本文整理汇总了Java中com.amazonaws.services.sqs.model.DeleteMessageBatchRequest的典型用法代码示例。如果您正苦于以下问题:Java DeleteMessageBatchRequest类的具体用法?Java DeleteMessageBatchRequest怎么用?Java DeleteMessageBatchRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DeleteMessageBatchRequest类属于com.amazonaws.services.sqs.model包,在下文中一共展示了DeleteMessageBatchRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: delete

import com.amazonaws.services.sqs.model.DeleteMessageBatchRequest; //导入依赖的package包/类
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.stream().forEach(m -> entries.add(new DeleteMessageBatchRequestEntry().withId(m.getId()).withReceiptHandle(m.getReceipt())));
      
      DeleteMessageBatchResult result = client.deleteMessageBatch(batch);
      List<String> failures = result.getFailed().stream().map(fm -> fm.getId()).collect(Collectors.toList());
logger.debug("failed to delete: {}", failures);
      return failures;

  }
 
开发者ID:Netflix,项目名称:conductor,代码行数:17,代码来源:SQSObservableQueue.java

示例2: releaseCompleteScanRanges

import com.amazonaws.services.sqs.model.DeleteMessageBatchRequest; //导入依赖的package包/类
@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));
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:20,代码来源:SQSScanWorkflow.java

示例3: handleMessages

import com.amazonaws.services.sqs.model.DeleteMessageBatchRequest; //导入依赖的package包/类
/***
 * Handle Messages
 * @param queue
 * @param sqsMessages
 */
private void handleMessages(final String queue, final List<com.amazonaws.services.sqs.model.Message> sqsMessages) {
	
	final List<Message> messages =  fromSqsMessages(queue, sqsMessages);
	if(CollectionUtil.hasElements(messages)){
		
		this.handler.handleBatch(messages);
		final List<DeleteMessageBatchRequestEntry> deleteEntries = new ArrayList<DeleteMessageBatchRequestEntry>();

		/*** TODO Allow the caller to specify messages to delete **/
		for(com.amazonaws.services.sqs.model.Message sqsMessage : sqsMessages){
			final DeleteMessageBatchRequestEntry entry = new DeleteMessageBatchRequestEntry(sqsMessage.getMessageId(), sqsMessage.getReceiptHandle());
			deleteEntries.add(entry);
		}
		/** Delete the message batch - TODO - This should actually Respect the feedback given from the handler on which messages to delete**/ 
		this.client.deleteMessageBatch(
				new DeleteMessageBatchRequest(this.queueUrl)
				.withEntries(deleteEntries));
	}
}
 
开发者ID:shagwood,项目名称:micro-genie,代码行数:25,代码来源:Poller.java

示例4: testSendReceiveDelete

import com.amazonaws.services.sqs.model.DeleteMessageBatchRequest; //导入依赖的package包/类
/**
 * 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())));
}
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:24,代码来源:SQSResourcesIntegrationTest.java

示例5: deleteMessageBatch

import com.amazonaws.services.sqs.model.DeleteMessageBatchRequest; //导入依赖的package包/类
@Override
public DeleteMessageBatchResult deleteMessageBatch(DeleteMessageBatchRequest deleteMessageBatchRequest) throws AmazonClientException {
    DirectorySQSQueue queue = getQueueFromUrl(deleteMessageBatchRequest.getQueueUrl(), false);
    //lists for reporting
    List<BatchResultErrorEntry> batchResultErrorEntries = new ArrayList<>();
    List<DeleteMessageBatchResultEntry> batchResultEntries = new ArrayList<>();
    //attempt delete on each
    for (DeleteMessageBatchRequestEntry batchRequestEntry : deleteMessageBatchRequest.getEntries()) {
        try {
            queue.delete(batchRequestEntry.getReceiptHandle());
            batchResultEntries.add(new DeleteMessageBatchResultEntry().withId(batchRequestEntry.getId()));
        } catch (IOException e) {
            BatchResultErrorEntry batchResultErrorEntry = new BatchResultErrorEntry().
                    withSenderFault(true).
                    withId(batchRequestEntry.getId()).
                    withMessage(e.getMessage());
            batchResultErrorEntries.add(batchResultErrorEntry);
        }
    }
    return new DeleteMessageBatchResult().withFailed(batchResultErrorEntries).withSuccessful(batchResultEntries);
}
 
开发者ID:bazaarvoice,项目名称:awslocal,代码行数:22,代码来源:DirectorySQS.java

示例6: createRequest

import com.amazonaws.services.sqs.model.DeleteMessageBatchRequest; //导入依赖的package包/类
@VisibleForTesting
static DeleteMessageBatchRequest createRequest(String queueUrl, Map<String, DeleteMessageEntry> entries) {
    return new DeleteMessageBatchRequest()
            .withQueueUrl(queueUrl)
            .withEntries(entries.entrySet().stream()
                    .map(keyValue -> new DeleteMessageBatchRequestEntry()
                            .withId(keyValue.getKey())
                            .withReceiptHandle(keyValue.getValue().getReceiptHandle())
                    ).collect(Collectors.toList()));
}
 
开发者ID:Bandwidth,项目名称:async-sqs,代码行数:11,代码来源:DeleteMessageBatchAction.java

示例7: createDeleteMessageBatchRequest

import com.amazonaws.services.sqs.model.DeleteMessageBatchRequest; //导入依赖的package包/类
@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;
}
 
开发者ID:riboseinc,项目名称:aws-codecommit-trigger-plugin,代码行数:14,代码来源:RequestFactoryImpl.java

示例8: deleteMessages

import com.amazonaws.services.sqs.model.DeleteMessageBatchRequest; //导入依赖的package包/类
@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();
}
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:11,代码来源:QueueImpl.java

示例9: action

import com.amazonaws.services.sqs.model.DeleteMessageBatchRequest; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:awslabs,项目名称:amazon-sqs-java-messaging-lib,代码行数:32,代码来源:RangedAcknowledger.java

示例10: testDeleteMessageBatchThrowAmazonClientException

import com.amazonaws.services.sqs.model.DeleteMessageBatchRequest; //导入依赖的package包/类
@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);
}
 
开发者ID:awslabs,项目名称:amazon-sqs-java-messaging-lib,代码行数:10,代码来源:AmazonSQSMessagingClientWrapperTest.java

示例11: testDeleteMessageBatchThrowAmazonServiceException

import com.amazonaws.services.sqs.model.DeleteMessageBatchRequest; //导入依赖的package包/类
@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);
}
 
开发者ID:awslabs,项目名称:amazon-sqs-java-messaging-lib,代码行数:10,代码来源:AmazonSQSMessagingClientWrapperTest.java

示例12: delete

import com.amazonaws.services.sqs.model.DeleteMessageBatchRequest; //导入依赖的package包/类
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);
}
 
开发者ID:Netflix,项目名称:s3mper,代码行数:16,代码来源:AlertJanitor.java

示例13: testCreateRequest

import com.amazonaws.services.sqs.model.DeleteMessageBatchRequest; //导入依赖的package包/类
@Test
public void testCreateRequest() {
    DeleteMessageBatchRequest request = DeleteMessageBatchAction.createRequest(QUEUE_URL, ENTRY_MAP);
    assertThat(request.getQueueUrl()).isEqualTo(QUEUE_URL);
    assertThat(request.getEntries().size()).isEqualTo(ENTRY_MAP.size());
}
 
开发者ID:Bandwidth,项目名称:async-sqs,代码行数:7,代码来源:DeleteMessageBatchActionTest.java

示例14: testBulkSendDelete_shouldWork

import com.amazonaws.services.sqs.model.DeleteMessageBatchRequest; //导入依赖的package包/类
@Test
public void testBulkSendDelete_shouldWork() {
  // create queue
  CreateQueueResult createdQueue = sqs.createQueue(new CreateQueueRequest().withQueueName("tea-earl-grey-queue"));
  // send batch
  SendMessageBatchRequestEntry firstRequest = new SendMessageBatchRequestEntry().withDelaySeconds(0).withId("one")
      .withMessageGroupId("groupee").withMessageBody("{\"XOXO\":234}");
  SendMessageBatchRequestEntry secondRequest = new SendMessageBatchRequestEntry().withDelaySeconds(0).withId("two")
      .withMessageGroupId("groupee").withMessageBody("{\"Quinoa\":\"Readymade\",\"vegan\":true}");
  SendMessageBatchRequestEntry thirdRequest = new SendMessageBatchRequestEntry().withDelaySeconds(0).withId("three")
      .withMessageGroupId("groupee").withMessageBody("{\"VHS\":\"street art slow-carb\"}");
  // verify send batch result
  SendMessageBatchResult sendResult = sqs.sendMessageBatch(new SendMessageBatchRequest().withQueueUrl(createdQueue.getQueueUrl())
      .withEntries(ImmutableList.of(firstRequest,secondRequest, thirdRequest)));
  assertNotNull("verify that batch send returned ok", sendResult);
  assertTrue("no request failed",sendResult.getFailed().isEmpty());
  assertEquals("verify successfull message count", 3, sendResult.getSuccessful().size());
  SendMessageBatchResultEntry firstResultEntry = sendResult.getSuccessful().stream().filter(msg -> msg.getId().equals("one")).findAny().get();
  assertEquals("verify correct message MD5",getAwsMessageMD5("{\"XOXO\":234}"),firstResultEntry.getMD5OfMessageBody());
  assertNotNull("verify message id exists",firstResultEntry.getMessageId());

  ReceiveMessageResult receivedMessagesResult = sqs.receiveMessage(new ReceiveMessageRequest().withQueueUrl(createdQueue.getQueueUrl()).withMaxNumberOfMessages(4));
  // delete batch
  List<DeleteMessageBatchRequestEntry> deleteRequests = new ArrayList<>();
  deleteRequests.add(new DeleteMessageBatchRequestEntry().withId("one").withReceiptHandle(receivedMessagesResult.getMessages().get(0).getReceiptHandle()));
  deleteRequests.add(new DeleteMessageBatchRequestEntry().withId("two").withReceiptHandle(receivedMessagesResult.getMessages().get(0).getReceiptHandle()));
  deleteRequests.add(new DeleteMessageBatchRequestEntry().withId("three").withReceiptHandle(receivedMessagesResult.getMessages().get(0).getReceiptHandle())); 
  
  DeleteMessageBatchResult deleteBatchResult = sqs.deleteMessageBatch(new DeleteMessageBatchRequest().withQueueUrl(createdQueue.getQueueUrl()).withEntries(deleteRequests));
  
  // verify delete batch result
  assertNotNull("verify that batch delete returned ok", deleteBatchResult);
  assertTrue("no request failed",deleteBatchResult.getFailed().isEmpty());
  assertEquals("verify successfull message count", 3, deleteBatchResult.getSuccessful().size());
  assertTrue("queue must be empty after removal",getQueues().get("tea-earl-grey-queue").getMessageQueue().isEmpty());
  for(Message message : receivedMessagesResult.getMessages()) {
    assertTrue("invisibility-queue must be empty after removal",getQueues().get("tea-earl-grey-queue").getInvisibilityQueueFor(message.getReceiptHandle()).isEmpty());
  }
  
  // cleanup
  getQueues().remove("tea-earl-grey-queue");
}
 
开发者ID:daflockinger,项目名称:unitstack,代码行数:43,代码来源:MockSqsTest.java

示例15: testBulkDelete_withEmptyRequestParams_shouldWork

import com.amazonaws.services.sqs.model.DeleteMessageBatchRequest; //导入依赖的package包/类
@Test
public void testBulkDelete_withEmptyRequestParams_shouldWork() {
  assertNotNull(sqs.deleteMessageBatch(new DeleteMessageBatchRequest()));
}
 
开发者ID:daflockinger,项目名称:unitstack,代码行数:5,代码来源:MockSqsTest.java


注:本文中的com.amazonaws.services.sqs.model.DeleteMessageBatchRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。