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

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

Introduction

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

Prototype


public java.util.Map<String, String> getAttributes() 

Source Link

Document

A map of attributes to set.

Usage

From source file:org.apache.camel.component.aws.sqs.AmazonSQSClientMock.java

License:Apache License

@Override
public void setQueueAttributes(SetQueueAttributesRequest setQueueAttributesRequest)
        throws AmazonServiceException, AmazonClientException {
    synchronized (queueAttributes) {
        if (!queueAttributes.containsKey(setQueueAttributesRequest.getQueueUrl())) {
            queueAttributes.put(setQueueAttributesRequest.getQueueUrl(), new HashMap<String, String>());
        }/*from   ww w  . j  a v a  2 s  .c  om*/
        for (final Map.Entry<String, String> entry : setQueueAttributesRequest.getAttributes().entrySet()) {
            queueAttributes.get(setQueueAttributesRequest.getQueueUrl()).put(entry.getKey(), entry.getValue());
        }
    }
}

From source file:org.apache.camel.component.aws.sqs.SqsEndpoint.java

License:Apache License

private void updateQueueAttributes(AmazonSQS client) {
    SetQueueAttributesRequest request = new SetQueueAttributesRequest();
    request.setQueueUrl(queueUrl);// w w  w  .j  a  v a 2s.c om
    if (getConfiguration().getDefaultVisibilityTimeout() != null) {
        request.getAttributes().put(QueueAttributeName.VisibilityTimeout.name(),
                String.valueOf(getConfiguration().getDefaultVisibilityTimeout()));
    }
    if (getConfiguration().getMaximumMessageSize() != null) {
        request.getAttributes().put(QueueAttributeName.MaximumMessageSize.name(),
                String.valueOf(getConfiguration().getMaximumMessageSize()));
    }
    if (getConfiguration().getMessageRetentionPeriod() != null) {
        request.getAttributes().put(QueueAttributeName.MessageRetentionPeriod.name(),
                String.valueOf(getConfiguration().getMessageRetentionPeriod()));
    }
    if (getConfiguration().getPolicy() != null) {
        request.getAttributes().put(QueueAttributeName.Policy.name(),
                String.valueOf(getConfiguration().getPolicy()));
    }
    if (getConfiguration().getReceiveMessageWaitTimeSeconds() != null) {
        request.getAttributes().put(QueueAttributeName.ReceiveMessageWaitTimeSeconds.name(),
                String.valueOf(getConfiguration().getReceiveMessageWaitTimeSeconds()));
    }
    if (!request.getAttributes().isEmpty()) {
        LOG.trace("Updating queue '{}' with the provided queue attributes...", configuration.getQueueName());
        client.setQueueAttributes(request);
        LOG.trace("Queue '{}' updated and available at {}'", configuration.getQueueName(), queueUrl);
    }
}