use of com.netflix.spinnaker.kork.pubsub.model.PubsubSubscriber 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);
}
Aggregations