Search in sources :

Example 1 with Builder

use of com.netflix.conductor.contribs.queue.sqs.SQSObservableQueue.Builder in project conductor by Netflix.

the class ContribsModule method getQueues.

@Provides
public Map<Status, ObservableQueue> getQueues(Configuration config, AWSCredentialsProvider acp) {
    String stack = "";
    if (config.getStack() != null && config.getStack().length() > 0) {
        stack = config.getStack() + "_";
    }
    Status[] statuses = new Status[] { Status.COMPLETED, Status.FAILED };
    Map<Status, ObservableQueue> queues = new HashMap<>();
    for (Status status : statuses) {
        String queueName = config.getProperty("workflow.listener.queue.prefix", config.getAppId() + "_sqs_notify_" + stack + status.name());
        AmazonSQSClient client = new AmazonSQSClient(acp);
        Builder builder = new SQSObservableQueue.Builder().withClient(client).withQueueName(queueName);
        String auth = config.getProperty("workflow.listener.queue.authorizedAccounts", "");
        String[] accounts = auth.split(",");
        for (String accountToAuthorize : accounts) {
            accountToAuthorize = accountToAuthorize.trim();
            if (accountToAuthorize.length() > 0) {
                builder.addAccountToAuthorize(accountToAuthorize.trim());
            }
        }
        ObservableQueue queue = builder.build();
        queues.put(status, queue);
    }
    return queues;
}
Also used : Status(com.netflix.conductor.common.metadata.tasks.Task.Status) HashMap(java.util.HashMap) SQSObservableQueue(com.netflix.conductor.contribs.queue.sqs.SQSObservableQueue) ObservableQueue(com.netflix.conductor.core.events.queue.ObservableQueue) Builder(com.netflix.conductor.contribs.queue.sqs.SQSObservableQueue.Builder) AmazonSQSClient(com.amazonaws.services.sqs.AmazonSQSClient) Provides(com.google.inject.Provides)

Aggregations

AmazonSQSClient (com.amazonaws.services.sqs.AmazonSQSClient)1 Provides (com.google.inject.Provides)1 Status (com.netflix.conductor.common.metadata.tasks.Task.Status)1 SQSObservableQueue (com.netflix.conductor.contribs.queue.sqs.SQSObservableQueue)1 Builder (com.netflix.conductor.contribs.queue.sqs.SQSObservableQueue.Builder)1 ObservableQueue (com.netflix.conductor.core.events.queue.ObservableQueue)1 HashMap (java.util.HashMap)1