Example usage for com.amazonaws ClientConfiguration DEFAULT_RETRY_POLICY

List of usage examples for com.amazonaws ClientConfiguration DEFAULT_RETRY_POLICY

Introduction

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

Prototype

RetryPolicy DEFAULT_RETRY_POLICY

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

Click Source Link

Document

Default request retry policy, including the maximum retry count of 3, the default retry condition and the default back-off strategy.

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);

    /*/*www.  ja v a2 s . 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;
}