Example usage for com.amazonaws.services.sns AmazonSNSAsyncClient AmazonSNSAsyncClient

List of usage examples for com.amazonaws.services.sns AmazonSNSAsyncClient AmazonSNSAsyncClient

Introduction

In this page you can find the example usage for com.amazonaws.services.sns AmazonSNSAsyncClient AmazonSNSAsyncClient.

Prototype

@Deprecated
public AmazonSNSAsyncClient(AWSCredentialsProvider awsCredentialsProvider,
        ClientConfiguration clientConfiguration, ExecutorService executorService) 

Source Link

Document

Constructs a new asynchronous client to invoke service methods on Amazon SNS using the specified AWS account credentials provider, executor service, and client configuration options.

Usage

From source file:com.intuit.tank.vmManager.environment.amazon.CloudwatchInstance.java

License:Open Source License

/**
 * /*from ww  w  .  ja v  a2 s  .  c  o m*/
 * @param request
 * @param vmRegion
 */
public CloudwatchInstance(VMRegion vmRegion) {
    // In case vmRegion is passed as null, use default region from settings file
    if (vmRegion == null) {
        vmRegion = config.getVmManagerConfig().getDefaultRegion();
    }
    try {
        CloudCredentials creds = config.getVmManagerConfig().getCloudCredentials(CloudProvider.amazon);
        AWSCredentials credentials = new BasicAWSCredentials(creds.getKeyId(), creds.getKey());
        ClientConfiguration clientConfig = new ClientConfiguration();
        clientConfig.setMaxConnections(2);
        if (StringUtils.isNotBlank(creds.getProxyHost())) {
            try {
                clientConfig.setProxyHost(creds.getProxyHost());

                if (StringUtils.isNotBlank(creds.getProxyPort())) {
                    clientConfig.setProxyPort(Integer.valueOf(creds.getProxyPort()));
                }
            } catch (NumberFormatException e) {
                logger.error("invalid proxy setup.");
            }

        }
        if (StringUtils.isNotBlank(creds.getKeyId()) && StringUtils.isNotBlank(creds.getKey())) {
            asynchCloudWatchClient = new AmazonCloudWatchAsyncClient(credentials, clientConfig,
                    Executors.newFixedThreadPool(2));
            asyncSnsClient = new AmazonSNSAsyncClient(credentials, clientConfig,
                    Executors.newFixedThreadPool(2));
        } else {
            asynchCloudWatchClient = new AmazonCloudWatchAsyncClient(clientConfig);
            asyncSnsClient = new AmazonSNSAsyncClient(clientConfig);
        }
        asynchCloudWatchClient.setRegion(Region.getRegion(Regions.fromName(vmRegion.getRegion())));
        asyncSnsClient.setRegion(Region.getRegion(Regions.fromName(vmRegion.getRegion())));
    } catch (Exception ex) {
        logger.error(ex.getMessage());
        throw new RuntimeException(ex);
    }
}

From source file:org.apache.usergrid.persistence.queue.impl.SNSQueueManagerImpl.java

License:Apache License

/**
 * The Asynchronous SNS client is used for publishing events to SNS.
 */// w  ww  . j  a va 2s. c  om

private AmazonSNSAsyncClient createAsyncSNSClient(final Region region, final ExecutorService executor) {

    final UsergridAwsCredentialsProvider ugProvider = new UsergridAwsCredentialsProvider();
    final AmazonSNSAsyncClient sns = new AmazonSNSAsyncClient(ugProvider.getCredentials(), clientConfiguration,
            executor);

    sns.setRegion(region);

    return sns;
}