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

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

Introduction

In this page you can find the example usage for com.amazonaws.services.sqs.model SendMessageBatchRequest 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  va 2  s  .co  m
 * Delivers up to ten messages to the specified queue. This is a batch
 * version of SendMessage. The result of the send action on each message is
 * reported individually in the response. Uploads message payloads to Amazon
 * S3 when necessary.
 * </p>
 * <p>
 * If the <code>DelaySeconds</code> parameter is not specified for an entry,
 * the default for the queue is used.
 * </p>
 * <p>
 * <b>IMPORTANT:</b>The following list shows the characters (in Unicode)
 * that are allowed in your message, according to the W3C XML specification.
 * For more information, go to http://www.faqs.org/rfcs/rfc1321.html. If you
 * send any characters that are not included in the list, your request will
 * be rejected. #x9 | #xA | #xD | [#x20 to #xD7FF] | [#xE000 to #xFFFD] |
 * [#x10000 to #x10FFFF]
 * </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>
 * <b>IMPORTANT:</b> The input object may be modified by the method. </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 sendMessageBatchRequest
 *            Container for the necessary parameters to execute the
 *            SendMessageBatch service method on AmazonSQS.
 * 
 * @return The response from the SendMessageBatch service method, as
 *         returned by AmazonSQS.
 * 
 * @throws BatchEntryIdsNotDistinctException
 * @throws TooManyEntriesInBatchRequestException
 * @throws BatchRequestTooLongException
 * @throws UnsupportedOperationException
 * @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 SendMessageBatchResult sendMessageBatch(SendMessageBatchRequest sendMessageBatchRequest) {

    if (sendMessageBatchRequest == null) {
        String errorMessage = "sendMessageBatchRequest cannot be null.";
        LOG.error(errorMessage);
        throw new AmazonClientException(errorMessage);
    }

    sendMessageBatchRequest.getRequestClientOptions()
            .appendUserAgent(SQSExtendedClientConstants.USER_AGENT_HEADER);

    if (!clientConfiguration.isLargePayloadSupportEnabled()) {
        return super.sendMessageBatch(sendMessageBatchRequest);
    }

    List<SendMessageBatchRequestEntry> batchEntries = sendMessageBatchRequest.getEntries();

    int index = 0;
    for (SendMessageBatchRequestEntry entry : batchEntries) {
        if (clientConfiguration.isAlwaysThroughS3() || isLarge(entry)) {
            batchEntries.set(index, storeMessageInS3(entry));
        }
        ++index;
    }

    return super.sendMessageBatch(sendMessageBatchRequest);
}