Search in sources :

Example 1 with AmazonSNSAsyncClient

use of com.amazonaws.services.sns.AmazonSNSAsyncClient in project metacat by Netflix.

the class SNSNotificationsConfig method amazonSNS.

/**
 * If SNS notifications are desired and no existing client has been created elsewhere
 * in the application create a default client here.
 * @param config       The system configuration abstraction to use
 * @param registry     registry for spectator
 * @return The configured SNS client
 */
// TODO: See what spring-cloud-aws would provide automatically...
@Bean
@ConditionalOnMissingBean(AmazonSNSAsync.class)
public AmazonSNSAsync amazonSNS(final Config config, final Registry registry) {
    final ExecutorService executor = Executors.newFixedThreadPool(config.getSnsClientThreadCount(), new ThreadFactoryBuilder().setNameFormat("metacat-sns-pool-%d").build());
    RegistryUtil.registerThreadPool(registry, "metacat-sns-pool", (ThreadPoolExecutor) executor);
    return new AmazonSNSAsyncClient(DefaultAWSCredentialsProviderChain.getInstance(), executor);
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) AmazonSNSAsyncClient(com.amazonaws.services.sns.AmazonSNSAsyncClient) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

AmazonSNSAsyncClient (com.amazonaws.services.sns.AmazonSNSAsyncClient)1 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 ExecutorService (java.util.concurrent.ExecutorService)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1