Example usage for com.amazonaws.services.sqs AmazonSQS setQueueAttributes

List of usage examples for com.amazonaws.services.sqs AmazonSQS setQueueAttributes

Introduction

In this page you can find the example usage for com.amazonaws.services.sqs AmazonSQS setQueueAttributes.

Prototype

SetQueueAttributesResult setQueueAttributes(String queueUrl, java.util.Map<String, String> attributes);

Source Link

Document

Simplified method form for invoking the SetQueueAttributes operation.

Usage

From source file:com.netflix.spinnaker.clouddriver.aws.lifecycle.InstanceTerminationLifecycleAgent.java

License:Apache License

private static String ensureQueueExists(AmazonSQS amazonSQS, ARN queueARN, ARN topicARN) {
    String queueUrl = amazonSQS.createQueue(queueARN.name).getQueueUrl();
    amazonSQS.setQueueAttributes(queueUrl,
            Collections.singletonMap("Policy", buildSQSPolicy(queueARN, topicARN).toJson()));

    return queueUrl;
}

From source file:com.netflix.spinnaker.clouddriver.aws.lifecycle.InstanceTerminationLifecycleWorker.java

License:Apache License

private static String ensureQueueExists(AmazonSQS amazonSQS, ARN queueARN, ARN topicARN,
        Set<String> terminatingRoleArns, int sqsMessageRetentionPeriodSeconds) {
    String queueUrl = amazonSQS.createQueue(queueARN.name).getQueueUrl();

    HashMap<String, String> attributes = new HashMap<>();
    attributes.put("Policy", buildSQSPolicy(queueARN, topicARN, terminatingRoleArns).toJson());
    attributes.put("MessageRetentionPeriod", Integer.toString(sqsMessageRetentionPeriodSeconds));
    amazonSQS.setQueueAttributes(queueUrl, attributes);

    return queueUrl;
}

From source file:com.netflix.spinnaker.clouddriver.aws.lifecycle.LaunchFailureNotificationAgent.java

License:Apache License

/**
 * Ensure that the queue exists and has a policy granting the source topic permission to send messages to it
 *///w w  w.j  av a 2  s  . c o m
private static String ensureQueueExists(AmazonSQS amazonSQS, ARN queueARN, ARN topicARN) {
    String queueUrl;

    try {
        queueUrl = amazonSQS.getQueueUrl(queueARN.name).getQueueUrl();
    } catch (Exception e) {
        queueUrl = amazonSQS.createQueue(queueARN.name).getQueueUrl();
    }

    amazonSQS.setQueueAttributes(queueUrl,
            Collections.singletonMap("Policy", buildSQSPolicy(queueARN, topicARN).toJson()));

    return queueUrl;
}

From source file:com.netflix.spinnaker.echo.pubsub.amazon.SQSSubscriber.java

License:Apache License

private static String ensureQueueExists(AmazonSQS amazonSQS, ARN queueARN, ARN topicARN,
        int sqsMessageRetentionPeriodSeconds) {
    String queueUrl = amazonSQS.createQueue(queueARN.getName()).getQueueUrl();
    log.debug("Created queue " + queueUrl);

    HashMap<String, String> attributes = new HashMap<>();
    attributes.put("Policy", buildSQSPolicy(queueARN, topicARN).toJson());
    attributes.put("MessageRetentionPeriod", Integer.toString(sqsMessageRetentionPeriodSeconds));
    amazonSQS.setQueueAttributes(queueUrl, attributes);

    return queueUrl;
}

From source file:com.netflix.spinnaker.kork.aws.pubsub.PubSubUtils.java

License:Apache License

public static String ensureQueueExists(AmazonSQS amazonSQS, ARN queueARN, ARN topicARN,
        int sqsMessageRetentionPeriodSeconds) {
    String queueUrl = amazonSQS.createQueue(queueARN.getName()).getQueueUrl();
    log.debug("Created queue " + queueUrl);

    HashMap<String, String> attributes = new HashMap<>();
    attributes.put("Policy", buildSQSPolicy(queueARN, topicARN).toJson());
    attributes.put("MessageRetentionPeriod", Integer.toString(sqsMessageRetentionPeriodSeconds));
    amazonSQS.setQueueAttributes(queueUrl, attributes);

    return queueUrl;
}