Example usage for com.amazonaws ClientConfiguration DEFAULT_USE_REAPER

List of usage examples for com.amazonaws ClientConfiguration DEFAULT_USE_REAPER

Introduction

In this page you can find the example usage for com.amazonaws ClientConfiguration DEFAULT_USE_REAPER.

Prototype

boolean DEFAULT_USE_REAPER

To view the source code for com.amazonaws ClientConfiguration DEFAULT_USE_REAPER.

Click Source Link

Document

The default on whether to use the IdleConnectionReaper to manage stale connections

Usage

From source file:com.zanox.vertx.mods.KinesisMessageProcessor.java

License:Apache License

private AmazonKinesisAsyncClient createClient() {

    // Building Kinesis configuration
    int connectionTimeout = getOptionalIntConfig(CONNECTION_TIMEOUT,
            ClientConfiguration.DEFAULT_CONNECTION_TIMEOUT);
    int maxConnection = getOptionalIntConfig(MAX_CONNECTION, ClientConfiguration.DEFAULT_MAX_CONNECTIONS);

    // TODO: replace default retry policy
    RetryPolicy retryPolicy = ClientConfiguration.DEFAULT_RETRY_POLICY;
    int socketTimeout = getOptionalIntConfig(SOCKET_TIMEOUT, ClientConfiguration.DEFAULT_SOCKET_TIMEOUT);
    boolean useReaper = getOptionalBooleanConfig(USE_REAPER, ClientConfiguration.DEFAULT_USE_REAPER);
    String userAgent = getOptionalStringConfig(USER_AGENT, ClientConfiguration.DEFAULT_USER_AGENT);

    streamName = getMandatoryStringConfig(STREAM_NAME);
    partitionKey = getMandatoryStringConfig(PARTITION_KEY);
    region = getMandatoryStringConfig(REGION);

    logger.info(" --- Stream name: " + streamName);
    logger.info(" --- Partition key: " + partitionKey);
    logger.info(" --- Region: " + region);

    ClientConfiguration clientConfiguration = new ClientConfiguration();
    clientConfiguration.setConnectionTimeout(connectionTimeout);
    clientConfiguration.setMaxConnections(maxConnection);
    clientConfiguration.setRetryPolicy(retryPolicy);
    clientConfiguration.setSocketTimeout(socketTimeout);
    clientConfiguration.setUseReaper(useReaper);
    clientConfiguration.setUserAgent(userAgent);

    /*// ww  w . j  ava2s. com
    AWS credentials provider chain that looks for credentials in this order:
       Environment Variables - AWS_ACCESS_KEY_ID and AWS_SECRET_KEY
       Java System Properties - aws.accessKeyId and aws.secretKey
       Credential profiles file at the default location (~/.aws/credentials) shared by all AWS SDKs and the AWS CLI
       Instance profile credentials delivered through the Amazon EC2 metadata service
    */

    AWSCredentialsProvider awsCredentialsProvider = new DefaultAWSCredentialsProviderChain();

    // Configuring Kinesis-client with configuration
    AmazonKinesisAsyncClient kinesisAsyncClient = new AmazonKinesisAsyncClient(awsCredentialsProvider,
            clientConfiguration);
    Region awsRegion = RegionUtils.getRegion(region);
    kinesisAsyncClient.setRegion(awsRegion);

    return kinesisAsyncClient;
}