Search in sources :

Example 1 with ARN

use of com.netflix.spinnaker.kork.aws.ARN in project kork by spinnaker.

the class SNSPublisherProvider method start.

@PostConstruct
public void start() {
    if (properties == null) {
        return;
    }
    List<PubsubPublisher> publishers = new ArrayList<>();
    properties.getSubscriptions().forEach((AmazonPubsubProperties.AmazonPubsubSubscription subscription) -> {
        ARN topicARN = new ARN(subscription.getTopicARN());
        log.info("Bootstrapping SNS topic: {}", topicARN);
        AmazonSNS amazonSNS = AmazonSNSClientBuilder.standard().withCredentials(awsCredentialsProvider).withClientConfiguration(new ClientConfiguration()).withRegion(topicARN.getRegion()).build();
        Supplier<Boolean> isEnabled = PubSubUtils.getEnabledSupplier(dynamicConfig, subscription, discoveryStatus);
        SNSPublisher publisher = new SNSPublisher(subscription, amazonSNS, isEnabled, registry, retrySupport);
        publishers.add(publisher);
    });
    pubsubPublishers.putAll(publishers);
}
Also used : PubsubPublisher(com.netflix.spinnaker.kork.pubsub.model.PubsubPublisher) ArrayList(java.util.ArrayList) ARN(com.netflix.spinnaker.kork.aws.ARN) ClientConfiguration(com.amazonaws.ClientConfiguration) AmazonSNS(com.amazonaws.services.sns.AmazonSNS) PostConstruct(javax.annotation.PostConstruct)

Example 2 with ARN

use of com.netflix.spinnaker.kork.aws.ARN in project kork by spinnaker.

the class SQSSubscriberProvider method start.

@PostConstruct
public void start() {
    Preconditions.checkNotNull(properties, "Can't initialize SQSSubscriberProvider with null properties");
    ExecutorService executorService = Executors.newFixedThreadPool(properties.getSubscriptions().size());
    List<PubsubSubscriber> subscribers = new ArrayList<>();
    properties.getSubscriptions().forEach((AmazonPubsubProperties.AmazonPubsubSubscription subscription) -> {
        log.info("Bootstrapping SQS for SNS topic: {}", subscription.getTopicARN());
        ARN queueArn = new ARN(subscription.getQueueARN());
        ARN topicArn = new ARN(subscription.getTopicARN());
        SQSSubscriber worker = new SQSSubscriber(subscription, pubsubMessageHandlerFactory.create(subscription), messageAcknowledger, AmazonSNSClientBuilder.standard().withCredentials(awsCredentialsProvider).withClientConfiguration(new ClientConfiguration()).withRegion(topicArn.getRegion()).build(), AmazonSQSClientBuilder.standard().withCredentials(awsCredentialsProvider).withClientConfiguration(new ClientConfiguration()).withRegion(queueArn.getRegion()).build(), PubSubUtils.getEnabledSupplier(dynamicConfig, subscription, discoveryStatus), registry);
        try {
            executorService.submit(worker);
            subscribers.add(worker);
            log.debug("Created worker {} for subscription: {}", worker.getWorkerName(), subscription.getName());
        } catch (RejectedExecutionException e) {
            log.error("Could not start {}", worker.getWorkerName(), e);
        }
    });
    pubsubSubscribers.putAll(subscribers);
}
Also used : PubsubSubscriber(com.netflix.spinnaker.kork.pubsub.model.PubsubSubscriber) ExecutorService(java.util.concurrent.ExecutorService) ArrayList(java.util.ArrayList) ARN(com.netflix.spinnaker.kork.aws.ARN) ClientConfiguration(com.amazonaws.ClientConfiguration) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) PostConstruct(javax.annotation.PostConstruct)

Aggregations

ClientConfiguration (com.amazonaws.ClientConfiguration)2 ARN (com.netflix.spinnaker.kork.aws.ARN)2 ArrayList (java.util.ArrayList)2 PostConstruct (javax.annotation.PostConstruct)2 AmazonSNS (com.amazonaws.services.sns.AmazonSNS)1 PubsubPublisher (com.netflix.spinnaker.kork.pubsub.model.PubsubPublisher)1 PubsubSubscriber (com.netflix.spinnaker.kork.pubsub.model.PubsubSubscriber)1 ExecutorService (java.util.concurrent.ExecutorService)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1