Java 类com.amazonaws.services.sns.AmazonSNSAsync 实例源码

项目:metacat    文件:SNSNotificationsConfig.java   
/**
 * SNS Notification Publisher.
 *
 * @param amazonSNS    The SNS client to use
 * @param config       The system configuration abstraction to use
 * @param objectMapper The object mapper to use
 * @param snsNotificationMetric The sns notification metric
 * @return Configured Notification Service bean
 */
@Bean
public SNSNotificationServiceImpl snsNotificationService(
    final AmazonSNSAsync amazonSNS,
    final Config config,
    final ObjectMapper objectMapper,
    final SNSNotificationMetric snsNotificationMetric
) {
    final String tableArn = config.getSnsTopicTableArn();
    if (StringUtils.isEmpty(tableArn)) {
        throw new IllegalStateException(
            "SNS Notifications are enabled but no table ARN provided. Unable to configure."
        );
    }
    final String partitionArn = config.getSnsTopicPartitionArn();
    if (StringUtils.isEmpty(partitionArn)) {
        throw new IllegalStateException(
            "SNS Notifications are enabled but no partition ARN provided. Unable to configure."
        );
    }

    log.info("SNS notifications are enabled. Creating SNSNotificationServiceImpl bean.");
    return new SNSNotificationServiceImpl(amazonSNS,
        tableArn, partitionArn, objectMapper, config, snsNotificationMetric);
}
项目:metacat    文件:SNSNotificationServiceImpl.java   
/**
 * Constructor.
 *
 * @param client             The SNS client to use to publish notifications
 * @param tableTopicArn      The topic to publish table related notifications to
 * @param partitionTopicArn  The topic to publish partition related notifications to
 * @param mapper             The object mapper to use to convert objects to JSON strings
 * @param config             The system config
 * @param notificationMetric The SNS notification metric
 */
public SNSNotificationServiceImpl(
    final AmazonSNSAsync client,
    @Size(min = 1) final String tableTopicArn,
    @Size(min = 1) final String partitionTopicArn,
    final ObjectMapper mapper,
    final Config config,
    final SNSNotificationMetric notificationMetric
) {

    this.client = client;
    this.tableTopicArn = tableTopicArn;
    this.partitionTopicArn = partitionTopicArn;
    this.mapper = mapper;
    this.config = config;
    this.notificationMetric = notificationMetric;
}
项目:metacat    文件:SNSNotificationsConfig.java   
/**
 * 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);
}
项目:izettle-toolbox    文件:AmazonSNSClientFactory.java   
/**
 * Creates Amazon SNS client for given endpoint using the provided credentials.
 *
 * @param awsCredentials AWS credentials with access to the endpoint, or null to use default aws credentials.
 * @return Amazon SNS client.
 */
private static AmazonSNSAsync createInstance(AWSCredentials awsCredentials) {
    if (awsCredentials == null) {
        return new AmazonSNSAsyncClient();
    } else {
        return new AmazonSNSAsyncClient(awsCredentials);
    }
}
项目:izettle-toolbox    文件:AmazonSNSClientFactory.java   
/**
 * Creates Amazon SNS client for given endpoint using the provided credentials.
 *
 * @param endpoint Amazon SNS endpoint.
 * @return Amazon SNS client.
 */
public static AmazonSNSAsync createInstance(String endpoint) {
    return createInstance(endpoint, null);
}
项目:izettle-toolbox    文件:AmazonSNSClientFactory.java   
/**
 * Creates Amazon SNS client for given endpoint using the provided credentials.
 *
 * @param endpoint Amazon SNS endpoint.
 * @param accessKey AWS credentials with access to the endpoint, or null to use default aws credentials.
 * @param secretKey AWS credentials with access to the endpoint.
 * @return Amazon SNS client.
 */
public static AmazonSNSAsync createInstance(String endpoint, String accessKey, String secretKey) {
    return createInstance(endpoint, AWSCredentialsWrapper.getCredentials(accessKey, secretKey));
}
项目:izettle-toolbox    文件:AmazonSNSClientFactory.java   
/**
 * Creates Amazon SNS client for given endpoint using the provided credentials.
 *
 * @param endpoint Amazon SNS endpoint.
 * @param awsCredentials AWS credentials with access to the endpoint, or null to use default aws credentials.
 * @return Amazon SNS client.
 */
public static AmazonSNSAsync createInstance(String endpoint, AWSCredentials awsCredentials) {
    AmazonSNSAsync client = createInstance(awsCredentials);
    client.setEndpoint(endpoint);
    return client;
}