Example usage for com.amazonaws.services.sqs.model SetQueueAttributesRequest setAttributes

List of usage examples for com.amazonaws.services.sqs.model SetQueueAttributesRequest setAttributes

Introduction

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

Prototype


public void setAttributes(java.util.Map<String, String> attributes) 

Source Link

Document

A map of attributes to set.

Usage

From source file:com.eucalyptus.portal.SimpleQueueClientManager.java

License:Open Source License

public void setQueueAttributes(final String queueName, final Map<String, String> queueAttributes)
        throws Exception {
    try {/*from   www.  j a v  a 2s .c o m*/
        final SetQueueAttributesRequest req = new SetQueueAttributesRequest();
        req.setAttributes(queueAttributes);
        req.setQueueUrl(getQueueUrl(queueName));
        getSimpleQueueClient().setQueueAttributes(req);
    } catch (final AmazonServiceException ex) {
        throw new Exception("Failed to set queue attributes due to service error", ex);
    } catch (final AmazonClientException ex) {
        throw new Exception("Failed to set queue attributes due to client error", ex);
    }
}

From source file:org.apache.usergrid.apm.service.ApplicationServiceImpl.java

License:Apache License

/**
 * //  ww  w  . j  a va 2s  .c  o  m
 * @param applicationId
 */
public void createSQSQueue(String orgAppName) {
    log.info("Creating Queue for App : " + orgAppName);
    CreateQueueRequest createQueueRequest = new CreateQueueRequest();
    createQueueRequest.setQueueName(AWSUtil.formQueueName(orgAppName));

    try {
        sqsClient.createQueue(createQueueRequest);

        //Need to do this to get QueueArn to apply right policy on that

        GetQueueAttributesRequest attributesRequest = new GetQueueAttributesRequest()
                .withQueueUrl(AWSUtil.formFullQueueUrl(orgAppName)).withAttributeNames("QueueArn");

        GetQueueAttributesResult attributesResult = sqsClient.getQueueAttributes(attributesRequest);
        String queueArn = attributesResult.getAttributes().get("QueueArn");

        SetQueueAttributesRequest setQueueAttributesRequest = new SetQueueAttributesRequest();
        Map<String, String> queueAttributes = new HashMap<String, String>();
        //Increasing the max size of SQS messages.
        queueAttributes.put("MaximumMessageSize", "65536");
        //Apply IP address white list
        String sqsPolicy = AWSUtil.getSQSIPAddressWhiteListPolicy(queueArn);
        log.info("For  queue " + queueArn + " with policy  json " + sqsPolicy);
        queueAttributes.put("Policy", sqsPolicy);
        setQueueAttributesRequest.setAttributes(queueAttributes);
        setQueueAttributesRequest.setQueueUrl(AWSUtil.formFullQueueUrl(orgAppName));
        sqsClient.setQueueAttributes(setQueueAttributesRequest);

    } catch (AmazonServiceException ase) {
        log.error("Problem creating queue in sqs");
        log.error(ase);
    } catch (AmazonClientException ace) {
        log.error(ace);
    }
}