public SqsClientTest() { QUEUE_ALREADY_EXISTS_EXCEPTION.setErrorCode(QUEUE_ALREADY_EXISTS); when(requestSenderMock.sendRequest(any(GetQueueUrlAction.class))) .thenReturn(Single.just(new GetQueueUrlResult().withQueueUrl(QUEUE_URL))); when(requestSenderMock.sendRequest(any(SetQueueAttributesAction.class))) .thenReturn(Single.just(new SetQueueAttributesResult())); when(requestSenderMock.sendRequest(any(GetQueueUrlAction.class))) .thenReturn(Single.just(new GetQueueUrlResult().withQueueUrl(QUEUE_URL))); }
private void addPolicy(List<String> accountsToAuthorize) { if(accountsToAuthorize == null || accountsToAuthorize.isEmpty()) { logger.info("No additional security policies attached for the queue " + queueName); return; } logger.info("Authorizing " + accountsToAuthorize + " to the queue " + queueName); Map<String, String> attributes = new HashMap<>(); attributes.put("Policy", getPolicy(accountsToAuthorize)); SetQueueAttributesResult result = client.setQueueAttributes(queueURL, attributes); logger.info("policy attachment result: " + result); logger.info("policy attachment result: status=" + result.getSdkHttpMetadata().getHttpStatusCode()); }
@Override public SetQueueAttributesResult setQueueAttributes(SetQueueAttributesRequest setQueueAttributesRequest) throws AmazonServiceException, AmazonClientException { synchronized (queueAttributes) { if (!queueAttributes.containsKey(setQueueAttributesRequest.getQueueUrl())) { queueAttributes.put(setQueueAttributesRequest.getQueueUrl(), new HashMap<String, String>()); } for (final Map.Entry<String, String> entry : setQueueAttributesRequest.getAttributes().entrySet()) { queueAttributes.get(setQueueAttributesRequest.getQueueUrl()).put(entry.getKey(), entry.getValue()); } } return new SetQueueAttributesResult(); }
public Observable<SetQueueAttributesResult> setQueueAttributesAsync(SetQueueAttributesRequest request) { return Observable.from(sqsClient.setQueueAttributesAsync(request)); }
public Observable<SetQueueAttributesResult> setQueueAttributesAsync(String queueUrl, Map<String, String> attributes) { return Observable.from(sqsClient.setQueueAttributesAsync(queueUrl, attributes)); }
@Override public SetQueueAttributesResult setQueueAttributes(SetQueueAttributesRequest setQueueAttributesRequest) throws AmazonServiceException, AmazonClientException { return new SetQueueAttributesResult(); }
/** * <p> * Sets the value of one or more queue attributes. When you change a queue's * attributes, the change can take up to 60 seconds for most of the * attributes to propagate throughout the SQS system. Changes made to the * <code>MessageRetentionPeriod</code> attribute can take up to 15 minutes. * </p> * <p> * <b>NOTE:</b>Going forward, new attributes might be added. If you are * writing code that calls this action, we recommend that you structure your * code so that it can handle new attributes gracefully. * </p> * * @param queueUrl * The URL of the Amazon SQS queue to take action on. * @param attributes * A map of attributes to set. * <p> * The following lists the names, descriptions, and values of the * special request parameters the <code>SetQueueAttributes</code> * action uses: * <p> * <ul> * <li><code>DelaySeconds</code> - The time in seconds that the * delivery of all messages in the queue will be delayed. An * integer from 0 to 900 (15 minutes). The default for this * attribute is 0 (zero).</li> * <li><code>MaximumMessageSize</code> - The limit of how many * bytes a message can contain before Amazon SQS rejects it. An * integer from 1024 bytes (1 KiB) up to 262144 bytes (256 KiB). * The default for this attribute is 262144 (256 KiB).</li> * <li><code>MessageRetentionPeriod</code> - The number of * seconds Amazon SQS retains a message. Integer representing * seconds, from 60 (1 minute) to 1209600 (14 days). The default * for this attribute is 345600 (4 days).</li> * <li><code>Policy</code> - The queue's policy. A valid AWS * policy. For more information about policy structure, see <a * href= * "http://docs.aws.amazon.com/IAM/latest/UserGuide/PoliciesOverview.html" * >Overview of AWS IAM Policies</a> in the <i>Amazon IAM User * Guide</i>.</li> * <li><code>ReceiveMessageWaitTimeSeconds</code> - The time for * which a ReceiveMessage call will wait for a message to arrive. * An integer from 0 to 20 (seconds). The default for this * attribute is 0.</li> * <li><code>VisibilityTimeout</code> - The visibility timeout * for the queue. An integer from 0 to 43200 (12 hours). The * default for this attribute is 30. For more information about * visibility timeout, see Visibility Timeout in the <i>Amazon * SQS Developer Guide</i>.</li> * <li><code>RedrivePolicy</code> - The parameters for dead * letter queue functionality of the source queue. For more * information about RedrivePolicy and dead letter queues, see * Using Amazon SQS Dead Letter Queues in the <i>Amazon SQS * Developer Guide</i>.</li> * </ul> * * @return The response from the SetQueueAttributes service method, as * returned by AmazonSQS. * * @throws InvalidAttributeNameException * * @throws AmazonClientException * If any internal errors are encountered inside the client * while attempting to make the request or handle the response. * For example if a network connection is not available. * @throws AmazonServiceException * If an error response is returned by AmazonSQS indicating * either a problem with the data in the request, or a server * side issue. */ public SetQueueAttributesResult setQueueAttributes(String queueUrl, Map<String, String> attributes) throws AmazonServiceException, AmazonClientException { return amazonSqsToBeExtended.setQueueAttributes(queueUrl, attributes); }
/** * <p> * Sets the value of one or more queue attributes. When you change a queue's * attributes, the change can take up to 60 seconds for most of the * attributes to propagate throughout the SQS system. Changes made to the * <code>MessageRetentionPeriod</code> attribute can take up to 15 minutes. * </p> * <p> * <b>NOTE:</b>Going forward, new attributes might be added. If you are * writing code that calls this action, we recommend that you structure your * code so that it can handle new attributes gracefully. * </p> * * @param setQueueAttributesRequest * Container for the necessary parameters to execute the * SetQueueAttributes service method on AmazonSQS. * * * @throws InvalidAttributeNameException * * @throws AmazonClientException * If any internal errors are encountered inside the client * while attempting to make the request or handle the response. * For example if a network connection is not available. * @throws AmazonServiceException * If an error response is returned by AmazonSQS indicating * either a problem with the data in the request, or a server * side issue. */ public SetQueueAttributesResult setQueueAttributes(SetQueueAttributesRequest setQueueAttributesRequest) throws AmazonServiceException, AmazonClientException { return amazonSqsToBeExtended.setQueueAttributes(setQueueAttributesRequest); }