Example usage for com.amazonaws.services.sqs.model DeleteMessageBatchRequest getRequestClientOptions

List of usage examples for com.amazonaws.services.sqs.model DeleteMessageBatchRequest getRequestClientOptions

Introduction

In this page you can find the example usage for com.amazonaws.services.sqs.model DeleteMessageBatchRequest getRequestClientOptions.

Prototype

public RequestClientOptions getRequestClientOptions() 

Source Link

Document

Gets the options stored with this request object.

Usage

From source file:com.amazon.sqs.javamessaging.AmazonSQSExtendedClient.java

License:Open Source License

/**
 * <p>/* w  w w.j a v a2s. 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 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);
}