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


Java DeleteMessageBatchRequest.getEntries方法代码示例

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


在下文中一共展示了DeleteMessageBatchRequest.getEntries方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: deleteMessageBatch

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


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