1 /*
2  * Copyright 2015-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5  * the License. A copy of the License is located at
6  * 
7  * http://aws.amazon.com/apache2.0
8  * 
9  * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10  * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11  * and limitations under the License.
12  */

13 package com.amazonaws.services.sqs;
14
15 import org.w3c.dom.*;
16
17 import java.net.*;
18 import java.util.*;
19
20 import javax.annotation.Generated;
21
22 import org.apache.commons.logging.*;
23
24 import com.amazonaws.*;
25 import com.amazonaws.annotation.SdkInternalApi;
26 import com.amazonaws.auth.*;
27
28 import com.amazonaws.handlers.*;
29 import com.amazonaws.http.*;
30 import com.amazonaws.internal.*;
31 import com.amazonaws.internal.auth.*;
32 import com.amazonaws.metrics.*;
33 import com.amazonaws.regions.*;
34 import com.amazonaws.transform.*;
35 import com.amazonaws.util.*;
36 import com.amazonaws.protocol.json.*;
37 import com.amazonaws.util.AWSRequestMetrics.Field;
38 import com.amazonaws.annotation.ThreadSafe;
39 import com.amazonaws.client.AwsSyncClientParams;
40 import com.amazonaws.client.builder.AdvancedConfig;
41
42 import com.amazonaws.services.sqs.AmazonSQSClientBuilder;
43
44 import com.amazonaws.AmazonServiceException;
45
46 import com.amazonaws.services.sqs.model.*;
47 import com.amazonaws.services.sqs.model.transform.*;
48
49 /**
50  * Client for accessing Amazon SQS. All service calls made using this client are blocking, and will not return until the
51  * service call completes.
52  * <p>
53  * <p>
54  * Welcome to the <i>Amazon Simple Queue Service API Reference</i>.
55  * </p>
56  * <p>
57  * Amazon Simple Queue Service (Amazon SQS) is a reliable, highly-scalable hosted queue for storing messages as they
58  * travel between applications or microservices. Amazon SQS moves data between distributed application components and
59  * helps you decouple these components.
60  * </p>
61  * <p>
62  * You can use <a href="http://aws.amazon.com/tools/#sdk">AWS SDKs</a> to access Amazon SQS using your favorite
63  * programming language. The SDKs perform tasks such as the following automatically:
64  * </p>
65  * <ul>
66  * <li>
67  * <p>
68  * Cryptographically sign your service requests
69  * </p>
70  * </li>
71  * <li>
72  * <p>
73  * Retry requests
74  * </p>
75  * </li>
76  * <li>
77  * <p>
78  * Handle error responses
79  * </p>
80  * </li>
81  * </ul>
82  * <p>
83  * <b>Additional Information</b>
84  * </p>
85  * <ul>
86  * <li>
87  * <p>
88  * <a href="http://aws.amazon.com/sqs/">Amazon SQS Product Page</a>
89  * </p>
90  * </li>
91  * <li>
92  * <p>
93  * <i>Amazon Simple Queue Service Developer Guide</i>
94  * </p>
95  * <ul>
96  * <li>
97  * <p>
98  * <a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-making-api-requests.html">
99  * Making API Requests</a>
100  * </p>
101  * </li>
102  * <li>
103  * <p>
104  * <a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-message-attributes.html">
105  * Amazon SQS Message Attributes</a>
106  * </p>
107  * </li>
108  * <li>
109  * <p>
110  * <a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html">
111  * Amazon SQS Dead-Letter Queues</a>
112  * </p>
113  * </li>
114  * </ul>
115  * </li>
116  * <li>
117  * <p>
118  * <a href="http://docs.aws.amazon.com/cli/latest/reference/sqs/index.html">Amazon SQS in the <i>AWS CLI Command
119  * Reference</i> </a>
120  * </p>
121  * </li>
122  * <li>
123  * <p>
124  * <i>Amazon Web Services General Reference</i>
125  * </p>
126  * <ul>
127  * <li>
128  * <p>
129  * <a href="https://docs.aws.amazon.com/general/latest/gr/rande.html#sqs_region">Regions and Endpoints</a>
130  * </p>
131  * </li>
132  * </ul>
133  * </li>
134  * </ul>
135  */

136 @ThreadSafe
137 @Generated("com.amazonaws:aws-java-sdk-code-generator")
138 public class AmazonSQSClient extends AmazonWebServiceClient implements AmazonSQS {
139
140     /** Provider for AWS credentials. */
141     private final AWSCredentialsProvider awsCredentialsProvider;
142
143     private static final Log log = LogFactory.getLog(AmazonSQS.class);
144
145     /** Default signing name for the service. */
146     private static final String DEFAULT_SIGNING_NAME = "sqs";
147
148     /** Client configuration factory providing ClientConfigurations tailored to this client */
149     protected static final com.amazonaws.services.sqs.AmazonSQSClientConfigurationFactory configFactory = new com.amazonaws.services.sqs.AmazonSQSClientConfigurationFactory();
150
151     private final AdvancedConfig advancedConfig;
152
153     /**
154      * List of exception unmarshallers for all modeled exceptions
155      */

156     protected final List<Unmarshaller<AmazonServiceException, Node>> exceptionUnmarshallers = new ArrayList<Unmarshaller<AmazonServiceException, Node>>();
157
158     /**
159      * Constructs a new client to invoke service methods on Amazon SQS. A credentials provider chain will be used that
160      * searches for credentials in this order:
161      * <ul>
162      * <li>Environment Variables - AWS_ACCESS_KEY_ID and AWS_SECRET_KEY</li>
163      * <li>Java System Properties - aws.accessKeyId and aws.secretKey</li>
164      * <li>Instance profile credentials delivered through the Amazon EC2 metadata service</li>
165      * </ul>
166      *
167      * <p>
168      * All service calls made using this new client object are blocking, and will not return until the service call
169      * completes.
170      *
171      * @see DefaultAWSCredentialsProviderChain
172      * @deprecated use {@link AmazonSQSClientBuilder#defaultClient()}
173      */

174     @Deprecated
175     public AmazonSQSClient() {
176         this(DefaultAWSCredentialsProviderChain.getInstance(), configFactory.getConfig());
177     }
178
179     /**
180      * Constructs a new client to invoke service methods on Amazon SQS. A credentials provider chain will be used that
181      * searches for credentials in this order:
182      * <ul>
183      * <li>Environment Variables - AWS_ACCESS_KEY_ID and AWS_SECRET_KEY</li>
184      * <li>Java System Properties - aws.accessKeyId and aws.secretKey</li>
185      * <li>Instance profile credentials delivered through the Amazon EC2 metadata service</li>
186      * </ul>
187      *
188      * <p>
189      * All service calls made using this new client object are blocking, and will not return until the service call
190      * completes.
191      *
192      * @param clientConfiguration
193      *        The client configuration options controlling how this client connects to Amazon SQS (ex: proxy settings,
194      *        retry counts, etc.).
195      *
196      * @see DefaultAWSCredentialsProviderChain
197      * @deprecated use {@link AmazonSQSClientBuilder#withClientConfiguration(ClientConfiguration)}
198      */

199     @Deprecated
200     public AmazonSQSClient(ClientConfiguration clientConfiguration) {
201         this(DefaultAWSCredentialsProviderChain.getInstance(), clientConfiguration);
202     }
203
204     /**
205      * Constructs a new client to invoke service methods on Amazon SQS using the specified AWS account credentials.
206      *
207      * <p>
208      * All service calls made using this new client object are blocking, and will not return until the service call
209      * completes.
210      *
211      * @param awsCredentials
212      *        The AWS credentials (access key ID and secret key) to use when authenticating with AWS services.
213      * @deprecated use {@link AmazonSQSClientBuilder#withCredentials(AWSCredentialsProvider)} for example:
214      *             {@code AmazonSQSClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(awsCredentials)).build();}
215      */

216     @Deprecated
217     public AmazonSQSClient(AWSCredentials awsCredentials) {
218         this(awsCredentials, configFactory.getConfig());
219     }
220
221     /**
222      * Constructs a new client to invoke service methods on Amazon SQS using the specified AWS account credentials and
223      * client configuration options.
224      *
225      * <p>
226      * All service calls made using this new client object are blocking, and will not return until the service call
227      * completes.
228      *
229      * @param awsCredentials
230      *        The AWS credentials (access key ID and secret key) to use when authenticating with AWS services.
231      * @param clientConfiguration
232      *        The client configuration options controlling how this client connects to Amazon SQS (ex: proxy settings,
233      *        retry counts, etc.).
234      * @deprecated use {@link AmazonSQSClientBuilder#withCredentials(AWSCredentialsProvider)} and
235      *             {@link AmazonSQSClientBuilder#withClientConfiguration(ClientConfiguration)}
236      */

237     @Deprecated
238     public AmazonSQSClient(AWSCredentials awsCredentials, ClientConfiguration clientConfiguration) {
239         super(clientConfiguration);
240         this.awsCredentialsProvider = new StaticCredentialsProvider(awsCredentials);
241         this.advancedConfig = AdvancedConfig.EMPTY;
242         init();
243     }
244
245     /**
246      * Constructs a new client to invoke service methods on Amazon SQS using the specified AWS account credentials
247      * provider.
248      *
249      * <p>
250      * All service calls made using this new client object are blocking, and will not return until the service call
251      * completes.
252      *
253      * @param awsCredentialsProvider
254      *        The AWS credentials provider which will provide credentials to authenticate requests with AWS services.
255      * @deprecated use {@link AmazonSQSClientBuilder#withCredentials(AWSCredentialsProvider)}
256      */

257     @Deprecated
258     public AmazonSQSClient(AWSCredentialsProvider awsCredentialsProvider) {
259         this(awsCredentialsProvider, configFactory.getConfig());
260     }
261
262     /**
263      * Constructs a new client to invoke service methods on Amazon SQS using the specified AWS account credentials
264      * provider and client configuration options.
265      *
266      * <p>
267      * All service calls made using this new client object are blocking, and will not return until the service call
268      * completes.
269      *
270      * @param awsCredentialsProvider
271      *        The AWS credentials provider which will provide credentials to authenticate requests with AWS services.
272      * @param clientConfiguration
273      *        The client configuration options controlling how this client connects to Amazon SQS (ex: proxy settings,
274      *        retry counts, etc.).
275      * @deprecated use {@link AmazonSQSClientBuilder#withCredentials(AWSCredentialsProvider)} and
276      *             {@link AmazonSQSClientBuilder#withClientConfiguration(ClientConfiguration)}
277      */

278     @Deprecated
279     public AmazonSQSClient(AWSCredentialsProvider awsCredentialsProvider, ClientConfiguration clientConfiguration) {
280         this(awsCredentialsProvider, clientConfiguration, null);
281     }
282
283     /**
284      * Constructs a new client to invoke service methods on Amazon SQS using the specified AWS account credentials
285      * provider, client configuration options, and request metric collector.
286      *
287      * <p>
288      * All service calls made using this new client object are blocking, and will not return until the service call
289      * completes.
290      *
291      * @param awsCredentialsProvider
292      *        The AWS credentials provider which will provide credentials to authenticate requests with AWS services.
293      * @param clientConfiguration
294      *        The client configuration options controlling how this client connects to Amazon SQS (ex: proxy settings,
295      *        retry counts, etc.).
296      * @param requestMetricCollector
297      *        optional request metric collector
298      * @deprecated use {@link AmazonSQSClientBuilder#withCredentials(AWSCredentialsProvider)} and
299      *             {@link AmazonSQSClientBuilder#withClientConfiguration(ClientConfiguration)} and
300      *             {@link AmazonSQSClientBuilder#withMetricsCollector(RequestMetricCollector)}
301      */

302     @Deprecated
303     public AmazonSQSClient(AWSCredentialsProvider awsCredentialsProvider, ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector) {
304         super(clientConfiguration, requestMetricCollector);
305         this.awsCredentialsProvider = awsCredentialsProvider;
306         this.advancedConfig = AdvancedConfig.EMPTY;
307         init();
308     }
309
310     public static AmazonSQSClientBuilder builder() {
311         return AmazonSQSClientBuilder.standard();
312     }
313
314     /**
315      * Constructs a new client to invoke service methods on Amazon SQS using the specified parameters.
316      *
317      * <p>
318      * All service calls made using this new client object are blocking, and will not return until the service call
319      * completes.
320      *
321      * @param clientParams
322      *        Object providing client parameters.
323      */

324     AmazonSQSClient(AwsSyncClientParams clientParams) {
325         this(clientParams, false);
326     }
327
328     /**
329      * Constructs a new client to invoke service methods on Amazon SQS using the specified parameters.
330      *
331      * <p>
332      * All service calls made using this new client object are blocking, and will not return until the service call
333      * completes.
334      *
335      * @param clientParams
336      *        Object providing client parameters.
337      */

338     AmazonSQSClient(AwsSyncClientParams clientParams, boolean endpointDiscoveryEnabled) {
339         super(clientParams);
340         this.awsCredentialsProvider = clientParams.getCredentialsProvider();
341         this.advancedConfig = clientParams.getAdvancedConfig();
342         init();
343     }
344
345     private void init() {
346         exceptionUnmarshallers.add(new PurgeQueueInProgressExceptionUnmarshaller());
347         exceptionUnmarshallers.add(new InvalidAttributeNameExceptionUnmarshaller());
348         exceptionUnmarshallers.add(new BatchEntryIdsNotDistinctExceptionUnmarshaller());
349         exceptionUnmarshallers.add(new TooManyEntriesInBatchRequestExceptionUnmarshaller());
350         exceptionUnmarshallers.add(new BatchRequestTooLongExceptionUnmarshaller());
351         exceptionUnmarshallers.add(new UnsupportedOperationExceptionUnmarshaller());
352         exceptionUnmarshallers.add(new InvalidIdFormatExceptionUnmarshaller());
353         exceptionUnmarshallers.add(new OverLimitExceptionUnmarshaller());
354         exceptionUnmarshallers.add(new QueueDoesNotExistExceptionUnmarshaller());
355         exceptionUnmarshallers.add(new QueueNameExistsExceptionUnmarshaller());
356         exceptionUnmarshallers.add(new MessageNotInflightExceptionUnmarshaller());
357         exceptionUnmarshallers.add(new ReceiptHandleIsInvalidExceptionUnmarshaller());
358         exceptionUnmarshallers.add(new InvalidMessageContentsExceptionUnmarshaller());
359         exceptionUnmarshallers.add(new QueueDeletedRecentlyExceptionUnmarshaller());
360         exceptionUnmarshallers.add(new EmptyBatchRequestExceptionUnmarshaller());
361         exceptionUnmarshallers.add(new InvalidBatchEntryIdExceptionUnmarshaller());
362         exceptionUnmarshallers.add(new StandardErrorUnmarshaller(com.amazonaws.services.sqs.model.AmazonSQSException.class));
363
364         setServiceNameIntern(DEFAULT_SIGNING_NAME);
365         setEndpointPrefix(ENDPOINT_PREFIX);
366         // calling this.setEndPoint(...) will also modify the signer accordingly
367         this.setEndpoint("https://sqs.us-east-1.amazonaws.com");
368         HandlerChainFactory chainFactory = new HandlerChainFactory();
369         requestHandler2s.addAll(chainFactory.newRequestHandlerChain("/com/amazonaws/services/sqs/request.handlers"));
370         requestHandler2s.addAll(chainFactory.newRequestHandler2Chain("/com/amazonaws/services/sqs/request.handler2s"));
371         requestHandler2s.addAll(chainFactory.getGlobalHandlers());
372     }
373
374     /**
375      * <p>
376      * Adds a permission to a queue for a specific <a
377      * href="https://docs.aws.amazon.com/general/latest/gr/glos-chap.html#P">principal</a>. This allows sharing access
378      * to the queue.
379      * </p>
380      * <p>
381      * When you create a queue, you have full control access rights for the queue. Only you, the owner of the queue, can
382      * grant or deny permissions to the queue. For more information about these permissions, see <a href=
383      * "https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-writing-an-sqs-policy.html#write-messages-to-shared-queue"
384      * >Allow Developers to Write Messages to a Shared Queue</a> in the <i>Amazon Simple Queue Service Developer
385      * Guide</i>.
386      * </p>
387      * <note>
388      * <ul>
389      * <li>
390      * <p>
391      * <code>AddPermission</code> generates a policy for you. You can use <code> <a>SetQueueAttributes</a> </code> to
392      * upload your policy. For more information, see <a href=
393      * "https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-creating-custom-policies.html"
394      * >Using Custom Policies with the Amazon SQS Access Policy Language</a> in the <i>Amazon Simple Queue Service
395      * Developer Guide</i>.
396      * </p>
397      * </li>
398      * <li>
399      * <p>
400      * An Amazon SQS policy can have a maximum of 7 actions.
401      * </p>
402      * </li>
403      * <li>
404      * <p>
405      * To remove the ability to change queue permissions, you must deny permission to the <code>AddPermission</code>,
406      * <code>RemovePermission</code>, and <code>SetQueueAttributes</code> actions in your IAM policy.
407      * </p>
408      * </li>
409      * </ul>
410      * </note>
411      * <p>
412      * Some actions take lists of parameters. These lists are specified using the <code>param.n</code> notation. Values
413      * of <code>n</code> are integers starting from 1. For example, a parameter list with two elements looks like this:
414      * </p>
415      * <p>
416      * <code>&amp;Attribute.1=first</code>
417      * </p>
418      * <p>
419      * <code>&amp;Attribute.2=second</code>
420      * </p>
421      * <note>
422      * <p>
423      * Cross-account permissions don't apply to this action. For more information, see <a href=
424      * "https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-customer-managed-policy-examples.html#grant-cross-account-permissions-to-role-and-user-name"
425      * >Grant Cross-Account Permissions to a Role and a User Name</a> in the <i>Amazon Simple Queue Service Developer
426      * Guide</i>.
427      * </p>
428      * </note>
429      * 
430      * @param addPermissionRequest
431      * @return Result of the AddPermission operation returned by the service.
432      * @throws OverLimitException
433      *         The specified action violates a limit. For example, <code>ReceiveMessage</code> returns this error if the
434      *         maximum number of inflight messages is reached and <code>AddPermission</code> returns this error if the
435      *         maximum number of permissions for the queue is reached.
436      * @sample AmazonSQS.AddPermission
437      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/AddPermission" target="_top">AWS API
438      *      Documentation</a>
439      */

440     @Override
441     public AddPermissionResult addPermission(AddPermissionRequest request) {
442         request = beforeClientExecution(request);
443         return executeAddPermission(request);
444     }
445
446     @SdkInternalApi
447     final AddPermissionResult executeAddPermission(AddPermissionRequest addPermissionRequest) {
448
449         ExecutionContext executionContext = createExecutionContext(addPermissionRequest);
450         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
451         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
452         Request<AddPermissionRequest> request = null;
453         Response<AddPermissionResult> response = null;
454
455         try {
456             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
457             try {
458                 request = new AddPermissionRequestMarshaller().marshall(super.beforeMarshalling(addPermissionRequest));
459                 // Binds the request metrics to the current request.
460                 request.setAWSRequestMetrics(awsRequestMetrics);
461                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
462                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SQS");
463                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "AddPermission");
464                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
465
466             } finally {
467                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
468             }
469
470             StaxResponseHandler<AddPermissionResult> responseHandler = new StaxResponseHandler<AddPermissionResult>(new AddPermissionResultStaxUnmarshaller());
471             response = invoke(request, responseHandler, executionContext);
472
473             return response.getAwsResponse();
474
475         } finally {
476
477             endClientExecution(awsRequestMetrics, request, response);
478         }
479     }
480
481     @Override
482     public AddPermissionResult addPermission(String queueUrl, String label, java.util.List<String> aWSAccountIds, java.util.List<String> actions) {
483         return addPermission(new AddPermissionRequest().withQueueUrl(queueUrl).withLabel(label).withAWSAccountIds(aWSAccountIds).withActions(actions));
484     }
485
486     /**
487      * <p>
488      * Changes the visibility timeout of a specified message in a queue to a new value. The default visibility timeout
489      * for a message is 30 seconds. The minimum is 0 seconds. The maximum is 12 hours. For more information, see <a
490      * href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html">
491      * Visibility Timeout</a> in the <i>Amazon Simple Queue Service Developer Guide</i>.
492      * </p>
493      * <p>
494      * For example, you have a message with a visibility timeout of 5 minutes. After 3 minutes, you call
495      * <code>ChangeMessageVisibility</code> with a timeout of 10 minutes. You can continue to call
496      * <code>ChangeMessageVisibility</code> to extend the visibility timeout to the maximum allowed time. If you try to
497      * extend the visibility timeout beyond the maximum, your request is rejected.
498      * </p>
499      * <p>
500      * An Amazon SQS message has three basic states:
501      * </p>
502      * <ol>
503      * <li>
504      * <p>
505      * Sent to a queue by a producer.
506      * </p>
507      * </li>
508      * <li>
509      * <p>
510      * Received from the queue by a consumer.
511      * </p>
512      * </li>
513      * <li>
514      * <p>
515      * Deleted from the queue.
516      * </p>
517      * </li>
518      * </ol>
519      * <p>
520      * A message is considered to be <i>stored</i> after it is sent to a queue by a producer, but not yet received from
521      * the queue by a consumer (that is, between states 1 and 2). There is no limit to the number of stored messages. A
522      * message is considered to be <i>in flight</i> after it is received from a queue by a consumer, but not yet deleted
523      * from the queue (that is, between states 2 and 3). There is a limit to the number of inflight messages.
524      * </p>
525      * <p>
526      * Limits that apply to inflight messages are unrelated to the <i>unlimited</i> number of stored messages.
527      * </p>
528      * <p>
529      * For most standard queues (depending on queue traffic and message backlog), there can be a maximum of
530      * approximately 120,000 inflight messages (received from a queue by a consumer, but not yet deleted from the
531      * queue). If you reach this limit, Amazon SQS returns the <code>OverLimit</code> error message. To avoid reaching
532      * the limit, you should delete messages from the queue after they're processed. You can also increase the number of
533      * queues you use to process your messages. To request a limit increase, <a href=
534      * "https://console.aws.amazon.com/support/home#/case/create?issueType=service-limit-increase&amp;limitType=service-code-sqs"
535      * >file a support request</a>.
536      * </p>
537      * <p>
538      * For FIFO queues, there can be a maximum of 20,000 inflight messages (received from a queue by a consumer, but not
539      * yet deleted from the queue). If you reach this limit, Amazon SQS returns no error messages.
540      * </p>
541      * <important>
542      * <p>
543      * If you attempt to set the <code>VisibilityTimeout</code> to a value greater than the maximum time left, Amazon
544      * SQS returns an error. Amazon SQS doesn't automatically recalculate and increase the timeout to the maximum
545      * remaining time.
546      * </p>
547      * <p>
548      * Unlike with a queue, when you change the visibility timeout for a specific message the timeout value is applied
549      * immediately but isn't saved in memory for that message. If you don't delete a message after it is received, the
550      * visibility timeout for the message reverts to the original timeout value (not to the value you set using the
551      * <code>ChangeMessageVisibility</code> action) the next time the message is received.
552      * </p>
553      * </important>
554      * 
555      * @param changeMessageVisibilityRequest
556      * @return Result of the ChangeMessageVisibility operation returned by the service.
557      * @throws MessageNotInflightException
558      *         The specified message isn't in flight.
559      * @throws ReceiptHandleIsInvalidException
560      *         The specified receipt handle isn't valid.
561      * @sample AmazonSQS.ChangeMessageVisibility
562      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/ChangeMessageVisibility" target="_top">AWS
563      *      API Documentation</a>
564      */

565     @Override
566     public ChangeMessageVisibilityResult changeMessageVisibility(ChangeMessageVisibilityRequest request) {
567         request = beforeClientExecution(request);
568         return executeChangeMessageVisibility(request);
569     }
570
571     @SdkInternalApi
572     final ChangeMessageVisibilityResult executeChangeMessageVisibility(ChangeMessageVisibilityRequest changeMessageVisibilityRequest) {
573
574         ExecutionContext executionContext = createExecutionContext(changeMessageVisibilityRequest);
575         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
576         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
577         Request<ChangeMessageVisibilityRequest> request = null;
578         Response<ChangeMessageVisibilityResult> response = null;
579
580         try {
581             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
582             try {
583                 request = new ChangeMessageVisibilityRequestMarshaller().marshall(super.beforeMarshalling(changeMessageVisibilityRequest));
584                 // Binds the request metrics to the current request.
585                 request.setAWSRequestMetrics(awsRequestMetrics);
586                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
587                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SQS");
588                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "ChangeMessageVisibility");
589                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
590
591             } finally {
592                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
593             }
594
595             StaxResponseHandler<ChangeMessageVisibilityResult> responseHandler = new StaxResponseHandler<ChangeMessageVisibilityResult>(
596                     new ChangeMessageVisibilityResultStaxUnmarshaller());
597             response = invoke(request, responseHandler, executionContext);
598
599             return response.getAwsResponse();
600
601         } finally {
602
603             endClientExecution(awsRequestMetrics, request, response);
604         }
605     }
606
607     @Override
608     public ChangeMessageVisibilityResult changeMessageVisibility(String queueUrl, String receiptHandle, Integer visibilityTimeout) {
609         return changeMessageVisibility(new ChangeMessageVisibilityRequest().withQueueUrl(queueUrl).withReceiptHandle(receiptHandle)
610                 .withVisibilityTimeout(visibilityTimeout));
611     }
612
613     /**
614      * <p>
615      * Changes the visibility timeout of multiple messages. This is a batch version of
616      * <code> <a>ChangeMessageVisibility</a>.</code> The result of the action on each message is reported individually
617      * in the response. You can send up to 10 <code> <a>ChangeMessageVisibility</a> </code> requests with each
618      * <code>ChangeMessageVisibilityBatch</code> action.
619      * </p>
620      * <important>
621      * <p>
622      * Because the batch request can result in a combination of successful and unsuccessful actions, you should check
623      * for batch errors even when the call returns an HTTP status code of <code>200</code>.
624      * </p>
625      * </important>
626      * <p>
627      * Some actions take lists of parameters. These lists are specified using the <code>param.n</code> notation. Values
628      * of <code>n</code> are integers starting from 1. For example, a parameter list with two elements looks like this:
629      * </p>
630      * <p>
631      * <code>&amp;Attribute.1=first</code>
632      * </p>
633      * <p>
634      * <code>&amp;Attribute.2=second</code>
635      * </p>
636      * 
637      * @param changeMessageVisibilityBatchRequest
638      * @return Result of the ChangeMessageVisibilityBatch operation returned by the service.
639      * @throws TooManyEntriesInBatchRequestException
640      *         The batch request contains more entries than permissible.
641      * @throws EmptyBatchRequestException
642      *         The batch request doesn't contain any entries.
643      * @throws BatchEntryIdsNotDistinctException
644      *         Two or more batch entries in the request have the same <code>Id</code>.
645      * @throws InvalidBatchEntryIdException
646      *         The <code>Id</code> of a batch entry in a batch request doesn't abide by the specification.
647      * @sample AmazonSQS.ChangeMessageVisibilityBatch
648      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/ChangeMessageVisibilityBatch"
649      *      target="_top">AWS API Documentation</a>
650      */

651     @Override
652     public ChangeMessageVisibilityBatchResult changeMessageVisibilityBatch(ChangeMessageVisibilityBatchRequest request) {
653         request = beforeClientExecution(request);
654         return executeChangeMessageVisibilityBatch(request);
655     }
656
657     @SdkInternalApi
658     final ChangeMessageVisibilityBatchResult executeChangeMessageVisibilityBatch(ChangeMessageVisibilityBatchRequest changeMessageVisibilityBatchRequest) {
659
660         ExecutionContext executionContext = createExecutionContext(changeMessageVisibilityBatchRequest);
661         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
662         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
663         Request<ChangeMessageVisibilityBatchRequest> request = null;
664         Response<ChangeMessageVisibilityBatchResult> response = null;
665
666         try {
667             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
668             try {
669                 request = new ChangeMessageVisibilityBatchRequestMarshaller().marshall(super.beforeMarshalling(changeMessageVisibilityBatchRequest));
670                 // Binds the request metrics to the current request.
671                 request.setAWSRequestMetrics(awsRequestMetrics);
672                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
673                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SQS");
674                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "ChangeMessageVisibilityBatch");
675                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
676
677             } finally {
678                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
679             }
680
681             StaxResponseHandler<ChangeMessageVisibilityBatchResult> responseHandler = new StaxResponseHandler<ChangeMessageVisibilityBatchResult>(
682                     new ChangeMessageVisibilityBatchResultStaxUnmarshaller());
683             response = invoke(request, responseHandler, executionContext);
684
685             return response.getAwsResponse();
686
687         } finally {
688
689             endClientExecution(awsRequestMetrics, request, response);
690         }
691     }
692
693     @Override
694     public ChangeMessageVisibilityBatchResult changeMessageVisibilityBatch(String queueUrl, java.util.List<ChangeMessageVisibilityBatchRequestEntry> entries) {
695         return changeMessageVisibilityBatch(new ChangeMessageVisibilityBatchRequest().withQueueUrl(queueUrl).withEntries(entries));
696     }
697
698     /**
699      * <p>
700      * Creates a new standard or FIFO queue. You can pass one or more attributes in the request. Keep the following
701      * caveats in mind:
702      * </p>
703      * <ul>
704      * <li>
705      * <p>
706      * If you don't specify the <code>FifoQueue</code> attribute, Amazon SQS creates a standard queue.
707      * </p>
708      * <note>
709      * <p>
710      * You can't change the queue type after you create it and you can't convert an existing standard queue into a FIFO
711      * queue. You must either create a new FIFO queue for your application or delete your existing standard queue and
712      * recreate it as a FIFO queue. For more information, see <a href=
713      * "https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html#FIFO-queues-moving"
714      * >Moving From a Standard Queue to a FIFO Queue</a> in the <i>Amazon Simple Queue Service Developer Guide</i>.
715      * </p>
716      * </note></li>
717      * <li>
718      * <p>
719      * If you don't provide a value for an attribute, the queue is created with the default value for the attribute.
720      * </p>
721      * </li>
722      * <li>
723      * <p>
724      * If you delete a queue, you must wait at least 60 seconds before creating a queue with the same name.
725      * </p>
726      * </li>
727      * </ul>
728      * <p>
729      * To successfully create a new queue, you must provide a queue name that adheres to the <a
730      * href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/limits-queues.html">limits
731      * related to queues</a> and is unique within the scope of your queues.
732      * </p>
733      * <p>
734      * To get the queue URL, use the <code> <a>GetQueueUrl</a> </code> action. <code> <a>GetQueueUrl</a> </code>
735      * requires only the <code>QueueName</code> parameter. be aware of existing queue names:
736      * </p>
737      * <ul>
738      * <li>
739      * <p>
740      * If you provide the name of an existing queue along with the exact names and values of all the queue's attributes,
741      * <code>CreateQueue</code> returns the queue URL for the existing queue.
742      * </p>
743      * </li>
744      * <li>
745      * <p>
746      * If the queue name, attribute names, or attribute values don't match an existing queue, <code>CreateQueue</code>
747      * returns an error.
748      * </p>
749      * </li>
750      * </ul>
751      * <p>
752      * Some actions take lists of parameters. These lists are specified using the <code>param.n</code> notation. Values
753      * of <code>n</code> are integers starting from 1. For example, a parameter list with two elements looks like this:
754      * </p>
755      * <p>
756      * <code>&amp;Attribute.1=first</code>
757      * </p>
758      * <p>
759      * <code>&amp;Attribute.2=second</code>
760      * </p>
761      * <note>
762      * <p>
763      * Cross-account permissions don't apply to this action. For more information, see <a href=
764      * "https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-customer-managed-policy-examples.html#grant-cross-account-permissions-to-role-and-user-name"
765      * >Grant Cross-Account Permissions to a Role and a User Name</a> in the <i>Amazon Simple Queue Service Developer
766      * Guide</i>.
767      * </p>
768      * </note>
769      * 
770      * @param createQueueRequest
771      * @return Result of the CreateQueue operation returned by the service.
772      * @throws QueueDeletedRecentlyException
773      *         You must wait 60 seconds after deleting a queue before you can create another queue with the same name.
774      * @throws QueueNameExistsException
775      *         A queue with this name already exists. Amazon SQS returns this error only if the request includes
776      *         attributes whose values differ from those of the existing queue.
777      * @sample AmazonSQS.CreateQueue
778      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/CreateQueue" target="_top">AWS API
779      *      Documentation</a>
780      */

781     @Override
782     public CreateQueueResult createQueue(CreateQueueRequest request) {
783         request = beforeClientExecution(request);
784         return executeCreateQueue(request);
785     }
786
787     @SdkInternalApi
788     final CreateQueueResult executeCreateQueue(CreateQueueRequest createQueueRequest) {
789
790         ExecutionContext executionContext = createExecutionContext(createQueueRequest);
791         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
792         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
793         Request<CreateQueueRequest> request = null;
794         Response<CreateQueueResult> response = null;
795
796         try {
797             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
798             try {
799                 request = new CreateQueueRequestMarshaller().marshall(super.beforeMarshalling(createQueueRequest));
800                 // Binds the request metrics to the current request.
801                 request.setAWSRequestMetrics(awsRequestMetrics);
802                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
803                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SQS");
804                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "CreateQueue");
805                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
806
807             } finally {
808                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
809             }
810
811             StaxResponseHandler<CreateQueueResult> responseHandler = new StaxResponseHandler<CreateQueueResult>(new CreateQueueResultStaxUnmarshaller());
812             response = invoke(request, responseHandler, executionContext);
813
814             return response.getAwsResponse();
815
816         } finally {
817
818             endClientExecution(awsRequestMetrics, request, response);
819         }
820     }
821
822     @Override
823     public CreateQueueResult createQueue(String queueName) {
824         return createQueue(new CreateQueueRequest().withQueueName(queueName));
825     }
826
827     /**
828      * <p>
829      * Deletes the specified message from the specified queue. To select the message to delete, use the
830      * <code>ReceiptHandle</code> of the message (<i>not</i> the <code>MessageId</code> which you receive when you send
831      * the message). Amazon SQS can delete a message from a queue even if a visibility timeout setting causes the
832      * message to be locked by another consumer. Amazon SQS automatically deletes messages left in a queue longer than
833      * the retention period configured for the queue.
834      * </p>
835      * <note>
836      * <p>
837      * The <code>ReceiptHandle</code> is associated with a <i>specific instance</i> of receiving a message. If you
838      * receive a message more than once, the <code>ReceiptHandle</code> is different each time you receive a message.
839      * When you use the <code>DeleteMessage</code> action, you must provide the most recently received
840      * <code>ReceiptHandle</code> for the message (otherwise, the request succeeds, but the message might not be
841      * deleted).
842      * </p>
843      * <p>
844      * For standard queues, it is possible to receive a message even after you delete it. This might happen on rare
845      * occasions if one of the servers which stores a copy of the message is unavailable when you send the request to
846      * delete the message. The copy remains on the server and might be returned to you during a subsequent receive
847      * request. You should ensure that your application is idempotent, so that receiving a message more than once does
848      * not cause issues.
849      * </p>
850      * </note>
851      * 
852      * @param deleteMessageRequest
853      * @return Result of the DeleteMessage operation returned by the service.
854      * @throws InvalidIdFormatException
855      *         The specified receipt handle isn't valid for the current version.
856      * @throws ReceiptHandleIsInvalidException
857      *         The specified receipt handle isn't valid.
858      * @sample AmazonSQS.DeleteMessage
859      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/DeleteMessage" target="_top">AWS API
860      *      Documentation</a>
861      */

862     @Override
863     public DeleteMessageResult deleteMessage(DeleteMessageRequest request) {
864         request = beforeClientExecution(request);
865         return executeDeleteMessage(request);
866     }
867
868     @SdkInternalApi
869     final DeleteMessageResult executeDeleteMessage(DeleteMessageRequest deleteMessageRequest) {
870
871         ExecutionContext executionContext = createExecutionContext(deleteMessageRequest);
872         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
873         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
874         Request<DeleteMessageRequest> request = null;
875         Response<DeleteMessageResult> response = null;
876
877         try {
878             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
879             try {
880                 request = new DeleteMessageRequestMarshaller().marshall(super.beforeMarshalling(deleteMessageRequest));
881                 // Binds the request metrics to the current request.
882                 request.setAWSRequestMetrics(awsRequestMetrics);
883                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
884                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SQS");
885                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "DeleteMessage");
886                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
887
888             } finally {
889                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
890             }
891
892             StaxResponseHandler<DeleteMessageResult> responseHandler = new StaxResponseHandler<DeleteMessageResult>(new DeleteMessageResultStaxUnmarshaller());
893             response = invoke(request, responseHandler, executionContext);
894
895             return response.getAwsResponse();
896
897         } finally {
898
899             endClientExecution(awsRequestMetrics, request, response);
900         }
901     }
902
903     @Override
904     public DeleteMessageResult deleteMessage(String queueUrl, String receiptHandle) {
905         return deleteMessage(new DeleteMessageRequest().withQueueUrl(queueUrl).withReceiptHandle(receiptHandle));
906     }
907
908     /**
909      * <p>
910      * Deletes up to ten messages from the specified queue. This is a batch version of
911      * <code> <a>DeleteMessage</a>.</code> The result of the action on each message is reported individually in the
912      * response.
913      * </p>
914      * <important>
915      * <p>
916      * Because the batch request can result in a combination of successful and unsuccessful actions, you should check
917      * for batch errors even when the call returns an HTTP status code of <code>200</code>.
918      * </p>
919      * </important>
920      * <p>
921      * Some actions take lists of parameters. These lists are specified using the <code>param.n</code> notation. Values
922      * of <code>n</code> are integers starting from 1. For example, a parameter list with two elements looks like this:
923      * </p>
924      * <p>
925      * <code>&amp;Attribute.1=first</code>
926      * </p>
927      * <p>
928      * <code>&amp;Attribute.2=second</code>
929      * </p>
930      * 
931      * @param deleteMessageBatchRequest
932      * @return Result of the DeleteMessageBatch operation returned by the service.
933      * @throws TooManyEntriesInBatchRequestException
934      *         The batch request contains more entries than permissible.
935      * @throws EmptyBatchRequestException
936      *         The batch request doesn't contain any entries.
937      * @throws BatchEntryIdsNotDistinctException
938      *         Two or more batch entries in the request have the same <code>Id</code>.
939      * @throws InvalidBatchEntryIdException
940      *         The <code>Id</code> of a batch entry in a batch request doesn't abide by the specification.
941      * @sample AmazonSQS.DeleteMessageBatch
942      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/DeleteMessageBatch" target="_top">AWS API
943      *      Documentation</a>
944      */

945     @Override
946     public DeleteMessageBatchResult deleteMessageBatch(DeleteMessageBatchRequest request) {
947         request = beforeClientExecution(request);
948         return executeDeleteMessageBatch(request);
949     }
950
951     @SdkInternalApi
952     final DeleteMessageBatchResult executeDeleteMessageBatch(DeleteMessageBatchRequest deleteMessageBatchRequest) {
953
954         ExecutionContext executionContext = createExecutionContext(deleteMessageBatchRequest);
955         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
956         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
957         Request<DeleteMessageBatchRequest> request = null;
958         Response<DeleteMessageBatchResult> response = null;
959
960         try {
961             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
962             try {
963                 request = new DeleteMessageBatchRequestMarshaller().marshall(super.beforeMarshalling(deleteMessageBatchRequest));
964                 // Binds the request metrics to the current request.
965                 request.setAWSRequestMetrics(awsRequestMetrics);
966                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
967                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SQS");
968                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "DeleteMessageBatch");
969                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
970
971             } finally {
972                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
973             }
974
975             StaxResponseHandler<DeleteMessageBatchResult> responseHandler = new StaxResponseHandler<DeleteMessageBatchResult>(
976                     new DeleteMessageBatchResultStaxUnmarshaller());
977             response = invoke(request, responseHandler, executionContext);
978
979             return response.getAwsResponse();
980
981         } finally {
982
983             endClientExecution(awsRequestMetrics, request, response);
984         }
985     }
986
987     @Override
988     public DeleteMessageBatchResult deleteMessageBatch(String queueUrl, java.util.List<DeleteMessageBatchRequestEntry> entries) {
989         return deleteMessageBatch(new DeleteMessageBatchRequest().withQueueUrl(queueUrl).withEntries(entries));
990     }
991
992     /**
993      * <p>
994      * Deletes the queue specified by the <code>QueueUrl</code>, regardless of the queue's contents. If the specified
995      * queue doesn't exist, Amazon SQS returns a successful response.
996      * </p>
997      * <important>
998      * <p>
999      * Be careful with the <code>DeleteQueue</code> action: When you delete a queue, any messages in the queue are no
1000      * longer available.
1001      * </p>
1002      * </important>
1003      * <p>
1004      * When you delete a queue, the deletion process takes up to 60 seconds. Requests you send involving that queue
1005      * during the 60 seconds might succeed. For example, a <code> <a>SendMessage</a> </code> request might succeed, but
1006      * after 60 seconds the queue and the message you sent no longer exist.
1007      * </p>
1008      * <p>
1009      * When you delete a queue, you must wait at least 60 seconds before creating a queue with the same name.
1010      * </p>
1011      * <note>
1012      * <p>
1013      * Cross-account permissions don't apply to this action. For more information, see <a href=
1014      * "https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-customer-managed-policy-examples.html#grant-cross-account-permissions-to-role-and-user-name"
1015      * >Grant Cross-Account Permissions to a Role and a User Name</a> in the <i>Amazon Simple Queue Service Developer
1016      * Guide</i>.
1017      * </p>
1018      * </note>
1019      * 
1020      * @param deleteQueueRequest
1021      * @return Result of the DeleteQueue operation returned by the service.
1022      * @sample AmazonSQS.DeleteQueue
1023      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/DeleteQueue" target="_top">AWS API
1024      *      Documentation</a>
1025      */

1026     @Override
1027     public DeleteQueueResult deleteQueue(DeleteQueueRequest request) {
1028         request = beforeClientExecution(request);
1029         return executeDeleteQueue(request);
1030     }
1031
1032     @SdkInternalApi
1033     final DeleteQueueResult executeDeleteQueue(DeleteQueueRequest deleteQueueRequest) {
1034
1035         ExecutionContext executionContext = createExecutionContext(deleteQueueRequest);
1036         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
1037         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
1038         Request<DeleteQueueRequest> request = null;
1039         Response<DeleteQueueResult> response = null;
1040
1041         try {
1042             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
1043             try {
1044                 request = new DeleteQueueRequestMarshaller().marshall(super.beforeMarshalling(deleteQueueRequest));
1045                 // Binds the request metrics to the current request.
1046                 request.setAWSRequestMetrics(awsRequestMetrics);
1047                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
1048                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SQS");
1049                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "DeleteQueue");
1050                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
1051
1052             } finally {
1053                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
1054             }
1055
1056             StaxResponseHandler<DeleteQueueResult> responseHandler = new StaxResponseHandler<DeleteQueueResult>(new DeleteQueueResultStaxUnmarshaller());
1057             response = invoke(request, responseHandler, executionContext);
1058
1059             return response.getAwsResponse();
1060
1061         } finally {
1062
1063             endClientExecution(awsRequestMetrics, request, response);
1064         }
1065     }
1066
1067     @Override
1068     public DeleteQueueResult deleteQueue(String queueUrl) {
1069         return deleteQueue(new DeleteQueueRequest().withQueueUrl(queueUrl));
1070     }
1071
1072     /**
1073      * <p>
1074      * Gets attributes for the specified queue.
1075      * </p>
1076      * <note>
1077      * <p>
1078      * To determine whether a queue is <a
1079      * href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html">FIFO</a>, you
1080      * can check whether <code>QueueName</code> ends with the <code>.fifo</code> suffix.
1081      * </p>
1082      * </note>
1083      * <p>
1084      * Some actions take lists of parameters. These lists are specified using the <code>param.n</code> notation. Values
1085      * of <code>n</code> are integers starting from 1. For example, a parameter list with two elements looks like this:
1086      * </p>
1087      * <p>
1088      * <code>&amp;Attribute.1=first</code>
1089      * </p>
1090      * <p>
1091      * <code>&amp;Attribute.2=second</code>
1092      * </p>
1093      * 
1094      * @param getQueueAttributesRequest
1095      * @return Result of the GetQueueAttributes operation returned by the service.
1096      * @throws InvalidAttributeNameException
1097      *         The specified attribute doesn't exist.
1098      * @sample AmazonSQS.GetQueueAttributes
1099      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/GetQueueAttributes" target="_top">AWS API
1100      *      Documentation</a>
1101      */

1102     @Override
1103     public GetQueueAttributesResult getQueueAttributes(GetQueueAttributesRequest request) {
1104         request = beforeClientExecution(request);
1105         return executeGetQueueAttributes(request);
1106     }
1107
1108     @SdkInternalApi
1109     final GetQueueAttributesResult executeGetQueueAttributes(GetQueueAttributesRequest getQueueAttributesRequest) {
1110
1111         ExecutionContext executionContext = createExecutionContext(getQueueAttributesRequest);
1112         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
1113         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
1114         Request<GetQueueAttributesRequest> request = null;
1115         Response<GetQueueAttributesResult> response = null;
1116
1117         try {
1118             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
1119             try {
1120                 request = new GetQueueAttributesRequestMarshaller().marshall(super.beforeMarshalling(getQueueAttributesRequest));
1121                 // Binds the request metrics to the current request.
1122                 request.setAWSRequestMetrics(awsRequestMetrics);
1123                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
1124                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SQS");
1125                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "GetQueueAttributes");
1126                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
1127
1128             } finally {
1129                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
1130             }
1131
1132             StaxResponseHandler<GetQueueAttributesResult> responseHandler = new StaxResponseHandler<GetQueueAttributesResult>(
1133                     new GetQueueAttributesResultStaxUnmarshaller());
1134             response = invoke(request, responseHandler, executionContext);
1135
1136             return response.getAwsResponse();
1137
1138         } finally {
1139
1140             endClientExecution(awsRequestMetrics, request, response);
1141         }
1142     }
1143
1144     @Override
1145     public GetQueueAttributesResult getQueueAttributes(String queueUrl, java.util.List<String> attributeNames) {
1146         return getQueueAttributes(new GetQueueAttributesRequest().withQueueUrl(queueUrl).withAttributeNames(attributeNames));
1147     }
1148
1149     /**
1150      * <p>
1151      * Returns the URL of an existing Amazon SQS queue.
1152      * </p>
1153      * <p>
1154      * To access a queue that belongs to another AWS account, use the <code>QueueOwnerAWSAccountId</code> parameter to
1155      * specify the account ID of the queue's owner. The queue's owner must grant you permission to access the queue. For
1156      * more information about shared queue access, see <code> <a>AddPermission</a> </code> or see <a href=
1157      * "https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-writing-an-sqs-policy.html#write-messages-to-shared-queue"
1158      * >Allow Developers to Write Messages to a Shared Queue</a> in the <i>Amazon Simple Queue Service Developer
1159      * Guide</i>.
1160      * </p>
1161      * 
1162      * @param getQueueUrlRequest
1163      * @return Result of the GetQueueUrl operation returned by the service.
1164      * @throws QueueDoesNotExistException
1165      *         The specified queue doesn't exist.
1166      * @sample AmazonSQS.GetQueueUrl
1167      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/GetQueueUrl" target="_top">AWS API
1168      *      Documentation</a>
1169      */

1170     @Override
1171     public GetQueueUrlResult getQueueUrl(GetQueueUrlRequest request) {
1172         request = beforeClientExecution(request);
1173         return executeGetQueueUrl(request);
1174     }
1175
1176     @SdkInternalApi
1177     final GetQueueUrlResult executeGetQueueUrl(GetQueueUrlRequest getQueueUrlRequest) {
1178
1179         ExecutionContext executionContext = createExecutionContext(getQueueUrlRequest);
1180         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
1181         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
1182         Request<GetQueueUrlRequest> request = null;
1183         Response<GetQueueUrlResult> response = null;
1184
1185         try {
1186             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
1187             try {
1188                 request = new GetQueueUrlRequestMarshaller().marshall(super.beforeMarshalling(getQueueUrlRequest));
1189                 // Binds the request metrics to the current request.
1190                 request.setAWSRequestMetrics(awsRequestMetrics);
1191                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
1192                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SQS");
1193                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "GetQueueUrl");
1194                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
1195
1196             } finally {
1197                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
1198             }
1199
1200             StaxResponseHandler<GetQueueUrlResult> responseHandler = new StaxResponseHandler<GetQueueUrlResult>(new GetQueueUrlResultStaxUnmarshaller());
1201             response = invoke(request, responseHandler, executionContext);
1202
1203             return response.getAwsResponse();
1204
1205         } finally {
1206
1207             endClientExecution(awsRequestMetrics, request, response);
1208         }
1209     }
1210
1211     @Override
1212     public GetQueueUrlResult getQueueUrl(String queueName) {
1213         return getQueueUrl(new GetQueueUrlRequest().withQueueName(queueName));
1214     }
1215
1216     /**
1217      * <p>
1218      * Returns a list of your queues that have the <code>RedrivePolicy</code> queue attribute configured with a
1219      * dead-letter queue.
1220      * </p>
1221      * <p>
1222      * For more information about using dead-letter queues, see <a
1223      * href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html"
1224      * >Using Amazon SQS Dead-Letter Queues</a> in the <i>Amazon Simple Queue Service Developer Guide</i>.
1225      * </p>
1226      * 
1227      * @param listDeadLetterSourceQueuesRequest
1228      * @return Result of the ListDeadLetterSourceQueues operation returned by the service.
1229      * @throws QueueDoesNotExistException
1230      *         The specified queue doesn't exist.
1231      * @sample AmazonSQS.ListDeadLetterSourceQueues
1232      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/ListDeadLetterSourceQueues" target="_top">AWS
1233      *      API Documentation</a>
1234      */

1235     @Override
1236     public ListDeadLetterSourceQueuesResult listDeadLetterSourceQueues(ListDeadLetterSourceQueuesRequest request) {
1237         request = beforeClientExecution(request);
1238         return executeListDeadLetterSourceQueues(request);
1239     }
1240
1241     @SdkInternalApi
1242     final ListDeadLetterSourceQueuesResult executeListDeadLetterSourceQueues(ListDeadLetterSourceQueuesRequest listDeadLetterSourceQueuesRequest) {
1243
1244         ExecutionContext executionContext = createExecutionContext(listDeadLetterSourceQueuesRequest);
1245         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
1246         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
1247         Request<ListDeadLetterSourceQueuesRequest> request = null;
1248         Response<ListDeadLetterSourceQueuesResult> response = null;
1249
1250         try {
1251             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
1252             try {
1253                 request = new ListDeadLetterSourceQueuesRequestMarshaller().marshall(super.beforeMarshalling(listDeadLetterSourceQueuesRequest));
1254                 // Binds the request metrics to the current request.
1255                 request.setAWSRequestMetrics(awsRequestMetrics);
1256                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
1257                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SQS");
1258                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "ListDeadLetterSourceQueues");
1259                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
1260
1261             } finally {
1262                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
1263             }
1264
1265             StaxResponseHandler<ListDeadLetterSourceQueuesResult> responseHandler = new StaxResponseHandler<ListDeadLetterSourceQueuesResult>(
1266                     new ListDeadLetterSourceQueuesResultStaxUnmarshaller());
1267             response = invoke(request, responseHandler, executionContext);
1268
1269             return response.getAwsResponse();
1270
1271         } finally {
1272
1273             endClientExecution(awsRequestMetrics, request, response);
1274         }
1275     }
1276
1277     /**
1278      * <p>
1279      * List all cost allocation tags added to the specified Amazon SQS queue. For an overview, see <a
1280      * href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-queue-tags.html">Tagging
1281      * Your Amazon SQS Queues</a> in the <i>Amazon Simple Queue Service Developer Guide</i>.
1282      * </p>
1283      * <note>
1284      * <p>
1285      * Cross-account permissions don't apply to this action. For more information, see <a href=
1286      * "https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-customer-managed-policy-examples.html#grant-cross-account-permissions-to-role-and-user-name"
1287      * >Grant Cross-Account Permissions to a Role and a User Name</a> in the <i>Amazon Simple Queue Service Developer
1288      * Guide</i>.
1289      * </p>
1290      * </note>
1291      * 
1292      * @param listQueueTagsRequest
1293      * @return Result of the ListQueueTags operation returned by the service.
1294      * @sample AmazonSQS.ListQueueTags
1295      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/ListQueueTags" target="_top">AWS API
1296      *      Documentation</a>
1297      */

1298     @Override
1299     public ListQueueTagsResult listQueueTags(ListQueueTagsRequest request) {
1300         request = beforeClientExecution(request);
1301         return executeListQueueTags(request);
1302     }
1303
1304     @SdkInternalApi
1305     final ListQueueTagsResult executeListQueueTags(ListQueueTagsRequest listQueueTagsRequest) {
1306
1307         ExecutionContext executionContext = createExecutionContext(listQueueTagsRequest);
1308         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
1309         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
1310         Request<ListQueueTagsRequest> request = null;
1311         Response<ListQueueTagsResult> response = null;
1312
1313         try {
1314             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
1315             try {
1316                 request = new ListQueueTagsRequestMarshaller().marshall(super.beforeMarshalling(listQueueTagsRequest));
1317                 // Binds the request metrics to the current request.
1318                 request.setAWSRequestMetrics(awsRequestMetrics);
1319                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
1320                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SQS");
1321                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "ListQueueTags");
1322                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
1323
1324             } finally {
1325                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
1326             }
1327
1328             StaxResponseHandler<ListQueueTagsResult> responseHandler = new StaxResponseHandler<ListQueueTagsResult>(new ListQueueTagsResultStaxUnmarshaller());
1329             response = invoke(request, responseHandler, executionContext);
1330
1331             return response.getAwsResponse();
1332
1333         } finally {
1334
1335             endClientExecution(awsRequestMetrics, request, response);
1336         }
1337     }
1338
1339     @Override
1340     public ListQueueTagsResult listQueueTags(String queueUrl) {
1341         return listQueueTags(new ListQueueTagsRequest().withQueueUrl(queueUrl));
1342     }
1343
1344     /**
1345      * <p>
1346      * Returns a list of your queues. The maximum number of queues that can be returned is 1,000. If you specify a value
1347      * for the optional <code>QueueNamePrefix</code> parameter, only queues with a name that begins with the specified
1348      * value are returned.
1349      * </p>
1350      * <note>
1351      * <p>
1352      * Cross-account permissions don't apply to this action. For more information, see <a href=
1353      * "https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-customer-managed-policy-examples.html#grant-cross-account-permissions-to-role-and-user-name"
1354      * >Grant Cross-Account Permissions to a Role and a User Name</a> in the <i>Amazon Simple Queue Service Developer
1355      * Guide</i>.
1356      * </p>
1357      * </note>
1358      * 
1359      * @param listQueuesRequest
1360      * @return Result of the ListQueues operation returned by the service.
1361      * @sample AmazonSQS.ListQueues
1362      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/ListQueues" target="_top">AWS API
1363      *      Documentation</a>
1364      */

1365     @Override
1366     public ListQueuesResult listQueues(ListQueuesRequest request) {
1367         request = beforeClientExecution(request);
1368         return executeListQueues(request);
1369     }
1370
1371     @SdkInternalApi
1372     final ListQueuesResult executeListQueues(ListQueuesRequest listQueuesRequest) {
1373
1374         ExecutionContext executionContext = createExecutionContext(listQueuesRequest);
1375         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
1376         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
1377         Request<ListQueuesRequest> request = null;
1378         Response<ListQueuesResult> response = null;
1379
1380         try {
1381             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
1382             try {
1383                 request = new ListQueuesRequestMarshaller().marshall(super.beforeMarshalling(listQueuesRequest));
1384                 // Binds the request metrics to the current request.
1385                 request.setAWSRequestMetrics(awsRequestMetrics);
1386                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
1387                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SQS");
1388                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "ListQueues");
1389                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
1390
1391             } finally {
1392                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
1393             }
1394
1395             StaxResponseHandler<ListQueuesResult> responseHandler = new StaxResponseHandler<ListQueuesResult>(new ListQueuesResultStaxUnmarshaller());
1396             response = invoke(request, responseHandler, executionContext);
1397
1398             return response.getAwsResponse();
1399
1400         } finally {
1401
1402             endClientExecution(awsRequestMetrics, request, response);
1403         }
1404     }
1405
1406     @Override
1407     public ListQueuesResult listQueues() {
1408         return listQueues(new ListQueuesRequest());
1409     }
1410
1411     @Override
1412     public ListQueuesResult listQueues(String queueNamePrefix) {
1413         return listQueues(new ListQueuesRequest().withQueueNamePrefix(queueNamePrefix));
1414     }
1415
1416     /**
1417      * <p>
1418      * Deletes the messages in a queue specified by the <code>QueueURL</code> parameter.
1419      * </p>
1420      * <important>
1421      * <p>
1422      * When you use the <code>PurgeQueue</code> action, you can't retrieve any messages deleted from a queue.
1423      * </p>
1424      * <p>
1425      * The message deletion process takes up to 60 seconds. We recommend waiting for 60 seconds regardless of your
1426      * queue's size.
1427      * </p>
1428      * </important>
1429      * <p>
1430      * Messages sent to the queue <i>before</i> you call <code>PurgeQueue</code> might be received but are deleted
1431      * within the next minute.
1432      * </p>
1433      * <p>
1434      * Messages sent to the queue <i>after</i> you call <code>PurgeQueue</code> might be deleted while the queue is
1435      * being purged.
1436      * </p>
1437      * 
1438      * @param purgeQueueRequest
1439      * @return Result of the PurgeQueue operation returned by the service.
1440      * @throws QueueDoesNotExistException
1441      *         The specified queue doesn't exist.
1442      * @throws PurgeQueueInProgressException
1443      *         Indicates that the specified queue previously received a <code>PurgeQueue</code> request within the last
1444      *         60 seconds (the time it can take to delete the messages in the queue).
1445      * @sample AmazonSQS.PurgeQueue
1446      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/PurgeQueue" target="_top">AWS API
1447      *      Documentation</a>
1448      */

1449     @Override
1450     public PurgeQueueResult purgeQueue(PurgeQueueRequest request) {
1451         request = beforeClientExecution(request);
1452         return executePurgeQueue(request);
1453     }
1454
1455     @SdkInternalApi
1456     final PurgeQueueResult executePurgeQueue(PurgeQueueRequest purgeQueueRequest) {
1457
1458         ExecutionContext executionContext = createExecutionContext(purgeQueueRequest);
1459         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
1460         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
1461         Request<PurgeQueueRequest> request = null;
1462         Response<PurgeQueueResult> response = null;
1463
1464         try {
1465             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
1466             try {
1467                 request = new PurgeQueueRequestMarshaller().marshall(super.beforeMarshalling(purgeQueueRequest));
1468                 // Binds the request metrics to the current request.
1469                 request.setAWSRequestMetrics(awsRequestMetrics);
1470                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
1471                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SQS");
1472                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "PurgeQueue");
1473                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
1474
1475             } finally {
1476                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
1477             }
1478
1479             StaxResponseHandler<PurgeQueueResult> responseHandler = new StaxResponseHandler<PurgeQueueResult>(new PurgeQueueResultStaxUnmarshaller());
1480             response = invoke(request, responseHandler, executionContext);
1481
1482             return response.getAwsResponse();
1483
1484         } finally {
1485
1486             endClientExecution(awsRequestMetrics, request, response);
1487         }
1488     }
1489
1490     /**
1491      * <p>
1492      * Retrieves one or more messages (up to 10), from the specified queue. Using the <code>WaitTimeSeconds</code>
1493      * parameter enables long-poll support. For more information, see <a
1494      * href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-long-polling.html">Amazon
1495      * SQS Long Polling</a> in the <i>Amazon Simple Queue Service Developer Guide</i>.
1496      * </p>
1497      * <p>
1498      * Short poll is the default behavior where a weighted random set of machines is sampled on a
1499      * <code>ReceiveMessage</code> call. Thus, only the messages on the sampled machines are returned. If the number of
1500      * messages in the queue is small (fewer than 1,000), you most likely get fewer messages than you requested per
1501      * <code>ReceiveMessage</code> call. If the number of messages in the queue is extremely small, you might not
1502      * receive any messages in a particular <code>ReceiveMessage</code> response. If this happens, repeat the request.
1503      * </p>
1504      * <p>
1505      * For each message returned, the response includes the following:
1506      * </p>
1507      * <ul>
1508      * <li>
1509      * <p>
1510      * The message body.
1511      * </p>
1512      * </li>
1513      * <li>
1514      * <p>
1515      * An MD5 digest of the message body. For information about MD5, see <a
1516      * href="https://www.ietf.org/rfc/rfc1321.txt">RFC1321</a>.
1517      * </p>
1518      * </li>
1519      * <li>
1520      * <p>
1521      * The <code>MessageId</code> you received when you sent the message to the queue.
1522      * </p>
1523      * </li>
1524      * <li>
1525      * <p>
1526      * The receipt handle.
1527      * </p>
1528      * </li>
1529      * <li>
1530      * <p>
1531      * The message attributes.
1532      * </p>
1533      * </li>
1534      * <li>
1535      * <p>
1536      * An MD5 digest of the message attributes.
1537      * </p>
1538      * </li>
1539      * </ul>
1540      * <p>
1541      * The receipt handle is the identifier you must provide when deleting the message. For more information, see <a
1542      * href
1543      * ="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-queue-message-identifiers.html"
1544      * >Queue and Message Identifiers</a> in the <i>Amazon Simple Queue Service Developer Guide</i>.
1545      * </p>
1546      * <p>
1547      * You can provide the <code>VisibilityTimeout</code> parameter in your request. The parameter is applied to the
1548      * messages that Amazon SQS returns in the response. If you don't include the parameter, the overall visibility
1549      * timeout for the queue is used for the returned messages. For more information, see <a
1550      * href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html"
1551      * >Visibility Timeout</a> in the <i>Amazon Simple Queue Service Developer Guide</i>.
1552      * </p>
1553      * <p>
1554      * A message that isn't deleted or a message whose visibility isn't extended before the visibility timeout expires
1555      * counts as a failed receive. Depending on the configuration of the queue, the message might be sent to the
1556      * dead-letter queue.
1557      * </p>
1558      * <note>
1559      * <p>
1560      * In the future, new attributes might be added. If you write code that calls this action, we recommend that you
1561      * structure your code so that it can handle new attributes gracefully.
1562      * </p>
1563      * </note>
1564      * 
1565      * @param receiveMessageRequest
1566      * @return Result of the ReceiveMessage operation returned by the service.
1567      * @throws OverLimitException
1568      *         The specified action violates a limit. For example, <code>ReceiveMessage</code> returns this error if the
1569      *         maximum number of inflight messages is reached and <code>AddPermission</code> returns this error if the
1570      *         maximum number of permissions for the queue is reached.
1571      * @sample AmazonSQS.ReceiveMessage
1572      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/ReceiveMessage" target="_top">AWS API
1573      *      Documentation</a>
1574      */

1575     @Override
1576     public ReceiveMessageResult receiveMessage(ReceiveMessageRequest request) {
1577         request = beforeClientExecution(request);
1578         return executeReceiveMessage(request);
1579     }
1580
1581     @SdkInternalApi
1582     final ReceiveMessageResult executeReceiveMessage(ReceiveMessageRequest receiveMessageRequest) {
1583
1584         ExecutionContext executionContext = createExecutionContext(receiveMessageRequest);
1585         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
1586         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
1587         Request<ReceiveMessageRequest> request = null;
1588         Response<ReceiveMessageResult> response = null;
1589
1590         try {
1591             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
1592             try {
1593                 request = new ReceiveMessageRequestMarshaller().marshall(super.beforeMarshalling(receiveMessageRequest));
1594                 // Binds the request metrics to the current request.
1595                 request.setAWSRequestMetrics(awsRequestMetrics);
1596                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
1597                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SQS");
1598                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "ReceiveMessage");
1599                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
1600
1601             } finally {
1602                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
1603             }
1604
1605             StaxResponseHandler<ReceiveMessageResult> responseHandler = new StaxResponseHandler<ReceiveMessageResult>(
1606                     new ReceiveMessageResultStaxUnmarshaller());
1607             response = invoke(request, responseHandler, executionContext);
1608
1609             return response.getAwsResponse();
1610
1611         } finally {
1612
1613             endClientExecution(awsRequestMetrics, request, response);
1614         }
1615     }
1616
1617     @Override
1618     public ReceiveMessageResult receiveMessage(String queueUrl) {
1619         return receiveMessage(new ReceiveMessageRequest().withQueueUrl(queueUrl));
1620     }
1621
1622     /**
1623      * <p>
1624      * Revokes any permissions in the queue policy that matches the specified <code>Label</code> parameter.
1625      * </p>
1626      * <note>
1627      * <ul>
1628      * <li>
1629      * <p>
1630      * Only the owner of a queue can remove permissions from it.
1631      * </p>
1632      * </li>
1633      * <li>
1634      * <p>
1635      * Cross-account permissions don't apply to this action. For more information, see <a href=
1636      * "https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-customer-managed-policy-examples.html#grant-cross-account-permissions-to-role-and-user-name"
1637      * >Grant Cross-Account Permissions to a Role and a User Name</a> in the <i>Amazon Simple Queue Service Developer
1638      * Guide</i>.
1639      * </p>
1640      * </li>
1641      * <li>
1642      * <p>
1643      * To remove the ability to change queue permissions, you must deny permission to the <code>AddPermission</code>,
1644      * <code>RemovePermission</code>, and <code>SetQueueAttributes</code> actions in your IAM policy.
1645      * </p>
1646      * </li>
1647      * </ul>
1648      * </note>
1649      * 
1650      * @param removePermissionRequest
1651      * @return Result of the RemovePermission operation returned by the service.
1652      * @sample AmazonSQS.RemovePermission
1653      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/RemovePermission" target="_top">AWS API
1654      *      Documentation</a>
1655      */

1656     @Override
1657     public RemovePermissionResult removePermission(RemovePermissionRequest request) {
1658         request = beforeClientExecution(request);
1659         return executeRemovePermission(request);
1660     }
1661
1662     @SdkInternalApi
1663     final RemovePermissionResult executeRemovePermission(RemovePermissionRequest removePermissionRequest) {
1664
1665         ExecutionContext executionContext = createExecutionContext(removePermissionRequest);
1666         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
1667         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
1668         Request<RemovePermissionRequest> request = null;
1669         Response<RemovePermissionResult> response = null;
1670
1671         try {
1672             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
1673             try {
1674                 request = new RemovePermissionRequestMarshaller().marshall(super.beforeMarshalling(removePermissionRequest));
1675                 // Binds the request metrics to the current request.
1676                 request.setAWSRequestMetrics(awsRequestMetrics);
1677                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
1678                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SQS");
1679                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "RemovePermission");
1680                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
1681
1682             } finally {
1683                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
1684             }
1685
1686             StaxResponseHandler<RemovePermissionResult> responseHandler = new StaxResponseHandler<RemovePermissionResult>(
1687                     new RemovePermissionResultStaxUnmarshaller());
1688             response = invoke(request, responseHandler, executionContext);
1689
1690             return response.getAwsResponse();
1691
1692         } finally {
1693
1694             endClientExecution(awsRequestMetrics, request, response);
1695         }
1696     }
1697
1698     @Override
1699     public RemovePermissionResult removePermission(String queueUrl, String label) {
1700         return removePermission(new RemovePermissionRequest().withQueueUrl(queueUrl).withLabel(label));
1701     }
1702
1703     /**
1704      * <p>
1705      * Delivers a message to the specified queue.
1706      * </p>
1707      * <important>
1708      * <p>
1709      * A message can include only XML, JSON, and unformatted text. The following Unicode characters are allowed:
1710      * </p>
1711      * <p>
1712      * <code>#x9</code> | <code>#xA</code> | <code>#xD</code> | <code>#x20</code> to <code>#xD7FF</code> |
1713      * <code>#xE000</code> to <code>#xFFFD</code> | <code>#x10000</code> to <code>#x10FFFF</code>
1714      * </p>
1715      * <p>
1716      * Any characters not included in this list will be rejected. For more information, see the <a
1717      * href="http://www.w3.org/TR/REC-xml/#charsets">W3C specification for characters</a>.
1718      * </p>
1719      * </important>
1720      * 
1721      * @param sendMessageRequest
1722      * @return Result of the SendMessage operation returned by the service.
1723      * @throws InvalidMessageContentsException
1724      *         The message contains characters outside the allowed set.
1725      * @throws UnsupportedOperationException
1726      *         Error code 400. Unsupported operation.
1727      * @sample AmazonSQS.SendMessage
1728      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/SendMessage" target="_top">AWS API
1729      *      Documentation</a>
1730      */

1731     @Override
1732     public SendMessageResult sendMessage(SendMessageRequest request) {
1733         request = beforeClientExecution(request);
1734         return executeSendMessage(request);
1735     }
1736
1737     @SdkInternalApi
1738     final SendMessageResult executeSendMessage(SendMessageRequest sendMessageRequest) {
1739
1740         ExecutionContext executionContext = createExecutionContext(sendMessageRequest);
1741         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
1742         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
1743         Request<SendMessageRequest> request = null;
1744         Response<SendMessageResult> response = null;
1745
1746         try {
1747             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
1748             try {
1749                 request = new SendMessageRequestMarshaller().marshall(super.beforeMarshalling(sendMessageRequest));
1750                 // Binds the request metrics to the current request.
1751                 request.setAWSRequestMetrics(awsRequestMetrics);
1752                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
1753                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SQS");
1754                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "SendMessage");
1755                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
1756
1757             } finally {
1758                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
1759             }
1760
1761             StaxResponseHandler<SendMessageResult> responseHandler = new StaxResponseHandler<SendMessageResult>(new SendMessageResultStaxUnmarshaller());
1762             response = invoke(request, responseHandler, executionContext);
1763
1764             return response.getAwsResponse();
1765
1766         } finally {
1767
1768             endClientExecution(awsRequestMetrics, request, response);
1769         }
1770     }
1771
1772     @Override
1773     public SendMessageResult sendMessage(String queueUrl, String messageBody) {
1774         return sendMessage(new SendMessageRequest().withQueueUrl(queueUrl).withMessageBody(messageBody));
1775     }
1776
1777     /**
1778      * <p>
1779      * Delivers up to ten messages to the specified queue. This is a batch version of <code> <a>SendMessage</a>.</code>
1780      * For a FIFO queue, multiple messages within a single batch are enqueued in the order they are sent.
1781      * </p>
1782      * <p>
1783      * The result of sending each message is reported individually in the response. Because the batch request can result
1784      * in a combination of successful and unsuccessful actions, you should check for batch errors even when the call
1785      * returns an HTTP status code of <code>200</code>.
1786      * </p>
1787      * <p>
1788      * The maximum allowed individual message size and the maximum total payload size (the sum of the individual lengths
1789      * of all of the batched messages) are both 256 KB (262,144 bytes).
1790      * </p>
1791      * <important>
1792      * <p>
1793      * A message can include only XML, JSON, and unformatted text. The following Unicode characters are allowed:
1794      * </p>
1795      * <p>
1796      * <code>#x9</code> | <code>#xA</code> | <code>#xD</code> | <code>#x20</code> to <code>#xD7FF</code> |
1797      * <code>#xE000</code> to <code>#xFFFD</code> | <code>#x10000</code> to <code>#x10FFFF</code>
1798      * </p>
1799      * <p>
1800      * Any characters not included in this list will be rejected. For more information, see the <a
1801      * href="http://www.w3.org/TR/REC-xml/#charsets">W3C specification for characters</a>.
1802      * </p>
1803      * </important>
1804      * <p>
1805      * If you don't specify the <code>DelaySeconds</code> parameter for an entry, Amazon SQS uses the default value for
1806      * the queue.
1807      * </p>
1808      * <p>
1809      * Some actions take lists of parameters. These lists are specified using the <code>param.n</code> notation. Values
1810      * of <code>n</code> are integers starting from 1. For example, a parameter list with two elements looks like this:
1811      * </p>
1812      * <p>
1813      * <code>&amp;Attribute.1=first</code>
1814      * </p>
1815      * <p>
1816      * <code>&amp;Attribute.2=second</code>
1817      * </p>
1818      * 
1819      * @param sendMessageBatchRequest
1820      * @return Result of the SendMessageBatch operation returned by the service.
1821      * @throws TooManyEntriesInBatchRequestException
1822      *         The batch request contains more entries than permissible.
1823      * @throws EmptyBatchRequestException
1824      *         The batch request doesn't contain any entries.
1825      * @throws BatchEntryIdsNotDistinctException
1826      *         Two or more batch entries in the request have the same <code>Id</code>.
1827      * @throws BatchRequestTooLongException
1828      *         The length of all the messages put together is more than the limit.
1829      * @throws InvalidBatchEntryIdException
1830      *         The <code>Id</code> of a batch entry in a batch request doesn't abide by the specification.
1831      * @throws UnsupportedOperationException
1832      *         Error code 400. Unsupported operation.
1833      * @sample AmazonSQS.SendMessageBatch
1834      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/SendMessageBatch" target="_top">AWS API
1835      *      Documentation</a>
1836      */

1837     @Override
1838     public SendMessageBatchResult sendMessageBatch(SendMessageBatchRequest request) {
1839         request = beforeClientExecution(request);
1840         return executeSendMessageBatch(request);
1841     }
1842
1843     @SdkInternalApi
1844     final SendMessageBatchResult executeSendMessageBatch(SendMessageBatchRequest sendMessageBatchRequest) {
1845
1846         ExecutionContext executionContext = createExecutionContext(sendMessageBatchRequest);
1847         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
1848         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
1849         Request<SendMessageBatchRequest> request = null;
1850         Response<SendMessageBatchResult> response = null;
1851
1852         try {
1853             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
1854             try {
1855                 request = new SendMessageBatchRequestMarshaller().marshall(super.beforeMarshalling(sendMessageBatchRequest));
1856                 // Binds the request metrics to the current request.
1857                 request.setAWSRequestMetrics(awsRequestMetrics);
1858                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
1859                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SQS");
1860                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "SendMessageBatch");
1861                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
1862
1863             } finally {
1864                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
1865             }
1866
1867             StaxResponseHandler<SendMessageBatchResult> responseHandler = new StaxResponseHandler<SendMessageBatchResult>(
1868                     new SendMessageBatchResultStaxUnmarshaller());
1869             response = invoke(request, responseHandler, executionContext);
1870
1871             return response.getAwsResponse();
1872
1873         } finally {
1874
1875             endClientExecution(awsRequestMetrics, request, response);
1876         }
1877     }
1878
1879     @Override
1880     public SendMessageBatchResult sendMessageBatch(String queueUrl, java.util.List<SendMessageBatchRequestEntry> entries) {
1881         return sendMessageBatch(new SendMessageBatchRequest().withQueueUrl(queueUrl).withEntries(entries));
1882     }
1883
1884     /**
1885      * <p>
1886      * Sets the value of one or more queue attributes. When you change a queue's attributes, the change can take up to
1887      * 60 seconds for most of the attributes to propagate throughout the Amazon SQS system. Changes made to the
1888      * <code>MessageRetentionPeriod</code> attribute can take up to 15 minutes.
1889      * </p>
1890      * <note>
1891      * <ul>
1892      * <li>
1893      * <p>
1894      * In the future, new attributes might be added. If you write code that calls this action, we recommend that you
1895      * structure your code so that it can handle new attributes gracefully.
1896      * </p>
1897      * </li>
1898      * <li>
1899      * <p>
1900      * Cross-account permissions don't apply to this action. For more information, see <a href=
1901      * "https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-customer-managed-policy-examples.html#grant-cross-account-permissions-to-role-and-user-name"
1902      * >Grant Cross-Account Permissions to a Role and a User Name</a> in the <i>Amazon Simple Queue Service Developer
1903      * Guide</i>.
1904      * </p>
1905      * </li>
1906      * <li>
1907      * <p>
1908      * To remove the ability to change queue permissions, you must deny permission to the <code>AddPermission</code>,
1909      * <code>RemovePermission</code>, and <code>SetQueueAttributes</code> actions in your IAM policy.
1910      * </p>
1911      * </li>
1912      * </ul>
1913      * </note>
1914      * 
1915      * @param setQueueAttributesRequest
1916      * @return Result of the SetQueueAttributes operation returned by the service.
1917      * @throws InvalidAttributeNameException
1918      *         The specified attribute doesn't exist.
1919      * @sample AmazonSQS.SetQueueAttributes
1920      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/SetQueueAttributes" target="_top">AWS API
1921      *      Documentation</a>
1922      */

1923     @Override
1924     public SetQueueAttributesResult setQueueAttributes(SetQueueAttributesRequest request) {
1925         request = beforeClientExecution(request);
1926         return executeSetQueueAttributes(request);
1927     }
1928
1929     @SdkInternalApi
1930     final SetQueueAttributesResult executeSetQueueAttributes(SetQueueAttributesRequest setQueueAttributesRequest) {
1931
1932         ExecutionContext executionContext = createExecutionContext(setQueueAttributesRequest);
1933         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
1934         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
1935         Request<SetQueueAttributesRequest> request = null;
1936         Response<SetQueueAttributesResult> response = null;
1937
1938         try {
1939             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
1940             try {
1941                 request = new SetQueueAttributesRequestMarshaller().marshall(super.beforeMarshalling(setQueueAttributesRequest));
1942                 // Binds the request metrics to the current request.
1943                 request.setAWSRequestMetrics(awsRequestMetrics);
1944                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
1945                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SQS");
1946                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "SetQueueAttributes");
1947                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
1948
1949             } finally {
1950                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
1951             }
1952
1953             StaxResponseHandler<SetQueueAttributesResult> responseHandler = new StaxResponseHandler<SetQueueAttributesResult>(
1954                     new SetQueueAttributesResultStaxUnmarshaller());
1955             response = invoke(request, responseHandler, executionContext);
1956
1957             return response.getAwsResponse();
1958
1959         } finally {
1960
1961             endClientExecution(awsRequestMetrics, request, response);
1962         }
1963     }
1964
1965     @Override
1966     public SetQueueAttributesResult setQueueAttributes(String queueUrl, java.util.Map<String, String> attributes) {
1967         return setQueueAttributes(new SetQueueAttributesRequest().withQueueUrl(queueUrl).withAttributes(attributes));
1968     }
1969
1970     /**
1971      * <p>
1972      * Add cost allocation tags to the specified Amazon SQS queue. For an overview, see <a
1973      * href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-queue-tags.html">Tagging
1974      * Your Amazon SQS Queues</a> in the <i>Amazon Simple Queue Service Developer Guide</i>.
1975      * </p>
1976      * <p>
1977      * When you use queue tags, keep the following guidelines in mind:
1978      * </p>
1979      * <ul>
1980      * <li>
1981      * <p>
1982      * Adding more than 50 tags to a queue isn't recommended.
1983      * </p>
1984      * </li>
1985      * <li>
1986      * <p>
1987      * Tags don't have any semantic meaning. Amazon SQS interprets tags as character strings.
1988      * </p>
1989      * </li>
1990      * <li>
1991      * <p>
1992      * Tags are case-sensitive.
1993      * </p>
1994      * </li>
1995      * <li>
1996      * <p>
1997      * A new tag with a key identical to that of an existing tag overwrites the existing tag.
1998      * </p>
1999      * </li>
2000      * </ul>
2001      * <p>
2002      * For a full list of tag restrictions, see <a
2003      * href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-limits.html#limits-queues"
2004      * >Limits Related to Queues</a> in the <i>Amazon Simple Queue Service Developer Guide</i>.
2005      * </p>
2006      * <note>
2007      * <p>
2008      * Cross-account permissions don't apply to this action. For more information, see <a href=
2009      * "https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-customer-managed-policy-examples.html#grant-cross-account-permissions-to-role-and-user-name"
2010      * >Grant Cross-Account Permissions to a Role and a User Name</a> in the <i>Amazon Simple Queue Service Developer
2011      * Guide</i>.
2012      * </p>
2013      * </note>
2014      * 
2015      * @param tagQueueRequest
2016      * @return Result of the TagQueue operation returned by the service.
2017      * @sample AmazonSQS.TagQueue
2018      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/TagQueue" target="_top">AWS API
2019      *      Documentation</a>
2020      */

2021     @Override
2022     public TagQueueResult tagQueue(TagQueueRequest request) {
2023         request = beforeClientExecution(request);
2024         return executeTagQueue(request);
2025     }
2026
2027     @SdkInternalApi
2028     final TagQueueResult executeTagQueue(TagQueueRequest tagQueueRequest) {
2029
2030         ExecutionContext executionContext = createExecutionContext(tagQueueRequest);
2031         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
2032         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
2033         Request<TagQueueRequest> request = null;
2034         Response<TagQueueResult> response = null;
2035
2036         try {
2037             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
2038             try {
2039                 request = new TagQueueRequestMarshaller().marshall(super.beforeMarshalling(tagQueueRequest));
2040                 // Binds the request metrics to the current request.
2041                 request.setAWSRequestMetrics(awsRequestMetrics);
2042                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
2043                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SQS");
2044                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "TagQueue");
2045                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
2046
2047             } finally {
2048                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
2049             }
2050
2051             StaxResponseHandler<TagQueueResult> responseHandler = new StaxResponseHandler<TagQueueResult>(new TagQueueResultStaxUnmarshaller());
2052             response = invoke(request, responseHandler, executionContext);
2053
2054             return response.getAwsResponse();
2055
2056         } finally {
2057
2058             endClientExecution(awsRequestMetrics, request, response);
2059         }
2060     }
2061
2062     @Override
2063     public TagQueueResult tagQueue(String queueUrl, java.util.Map<String, String> tags) {
2064         return tagQueue(new TagQueueRequest().withQueueUrl(queueUrl).withTags(tags));
2065     }
2066
2067     /**
2068      * <p>
2069      * Remove cost allocation tags from the specified Amazon SQS queue. For an overview, see <a
2070      * href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-queue-tags.html">Tagging
2071      * Your Amazon SQS Queues</a> in the <i>Amazon Simple Queue Service Developer Guide</i>.
2072      * </p>
2073      * <note>
2074      * <p>
2075      * Cross-account permissions don't apply to this action. For more information, see <a href=
2076      * "https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-customer-managed-policy-examples.html#grant-cross-account-permissions-to-role-and-user-name"
2077      * >Grant Cross-Account Permissions to a Role and a User Name</a> in the <i>Amazon Simple Queue Service Developer
2078      * Guide</i>.
2079      * </p>
2080      * </note>
2081      * 
2082      * @param untagQueueRequest
2083      * @return Result of the UntagQueue operation returned by the service.
2084      * @sample AmazonSQS.UntagQueue
2085      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/UntagQueue" target="_top">AWS API
2086      *      Documentation</a>
2087      */

2088     @Override
2089     public UntagQueueResult untagQueue(UntagQueueRequest request) {
2090         request = beforeClientExecution(request);
2091         return executeUntagQueue(request);
2092     }
2093
2094     @SdkInternalApi
2095     final UntagQueueResult executeUntagQueue(UntagQueueRequest untagQueueRequest) {
2096
2097         ExecutionContext executionContext = createExecutionContext(untagQueueRequest);
2098         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
2099         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
2100         Request<UntagQueueRequest> request = null;
2101         Response<UntagQueueResult> response = null;
2102
2103         try {
2104             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
2105             try {
2106                 request = new UntagQueueRequestMarshaller().marshall(super.beforeMarshalling(untagQueueRequest));
2107                 // Binds the request metrics to the current request.
2108                 request.setAWSRequestMetrics(awsRequestMetrics);
2109                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
2110                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SQS");
2111                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "UntagQueue");
2112                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
2113
2114             } finally {
2115                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
2116             }
2117
2118             StaxResponseHandler<UntagQueueResult> responseHandler = new StaxResponseHandler<UntagQueueResult>(new UntagQueueResultStaxUnmarshaller());
2119             response = invoke(request, responseHandler, executionContext);
2120
2121             return response.getAwsResponse();
2122
2123         } finally {
2124
2125             endClientExecution(awsRequestMetrics, request, response);
2126         }
2127     }
2128
2129     @Override
2130     public UntagQueueResult untagQueue(String queueUrl, java.util.List<String> tagKeys) {
2131         return untagQueue(new UntagQueueRequest().withQueueUrl(queueUrl).withTagKeys(tagKeys));
2132     }
2133
2134     /**
2135      * Returns additional metadata for a previously executed successful, request, typically used for debugging issues
2136      * where a service isn't acting as expected. This data isn't considered part of the result data returned by an
2137      * operation, so it's available through this separate, diagnostic interface.
2138      * <p>
2139      * Response metadata is only cached for a limited period of time, so if you need to access this extra diagnostic
2140      * information for an executed request, you should use this method to retrieve it as soon as possible after
2141      * executing the request.
2142      *
2143      * @param request
2144      *        The originally executed request
2145      *
2146      * @return The response metadata for the specified request, or null if none is available.
2147      */

2148     public ResponseMetadata getCachedResponseMetadata(AmazonWebServiceRequest request) {
2149         return client.getResponseMetadataForRequest(request);
2150     }
2151
2152     @Override
2153     protected final SignerProvider createSignerProvider(Signer signer) {
2154         return new com.amazonaws.services.sqs.internal.auth.SQSSignerProvider(this, signer);
2155     }
2156
2157     /**
2158      * Normal invoke with authentication. Credentials are required and may be overriden at the request level.
2159      **/

2160     private <X, Y extends AmazonWebServiceRequest> Response<X> invoke(Request<Y> request, HttpResponseHandler<AmazonWebServiceResponse<X>> responseHandler,
2161             ExecutionContext executionContext) {
2162
2163         return invoke(request, responseHandler, executionContext, nullnull);
2164     }
2165
2166     /**
2167      * Normal invoke with authentication. Credentials are required and may be overriden at the request level.
2168      **/

2169     private <X, Y extends AmazonWebServiceRequest> Response<X> invoke(Request<Y> request, HttpResponseHandler<AmazonWebServiceResponse<X>> responseHandler,
2170             ExecutionContext executionContext, URI cachedEndpoint, URI uriFromEndpointTrait) {
2171
2172         executionContext.setCredentialsProvider(CredentialUtils.getCredentialsProvider(request.getOriginalRequest(), awsCredentialsProvider));
2173
2174         return doInvoke(request, responseHandler, executionContext, cachedEndpoint, uriFromEndpointTrait);
2175     }
2176
2177     /**
2178      * Invoke with no authentication. Credentials are not required and any credentials set on the client or request will
2179      * be ignored for this operation.
2180      **/

2181     private <X, Y extends AmazonWebServiceRequest> Response<X> anonymousInvoke(Request<Y> request,
2182             HttpResponseHandler<AmazonWebServiceResponse<X>> responseHandler, ExecutionContext executionContext) {
2183
2184         return doInvoke(request, responseHandler, executionContext, nullnull);
2185     }
2186
2187     /**
2188      * Invoke the request using the http client. Assumes credentials (or lack thereof) have been configured in the
2189      * ExecutionContext beforehand.
2190      **/

2191     private <X, Y extends AmazonWebServiceRequest> Response<X> doInvoke(Request<Y> request, HttpResponseHandler<AmazonWebServiceResponse<X>> responseHandler,
2192             ExecutionContext executionContext, URI discoveredEndpoint, URI uriFromEndpointTrait) {
2193
2194         if (discoveredEndpoint != null) {
2195             request.setEndpoint(discoveredEndpoint);
2196             request.getOriginalRequest().getRequestClientOptions().appendUserAgent("endpoint-discovery");
2197         } else if (uriFromEndpointTrait != null) {
2198             request.setEndpoint(uriFromEndpointTrait);
2199         } else {
2200             request.setEndpoint(endpoint);
2201         }
2202
2203         request.setTimeOffset(timeOffset);
2204
2205         DefaultErrorResponseHandler errorResponseHandler = new DefaultErrorResponseHandler(exceptionUnmarshallers);
2206
2207         return client.execute(request, responseHandler, errorResponseHandler, executionContext);
2208     }
2209
2210 }
2211