Example usage for com.amazonaws.services.sqs AmazonSQSAsyncClient AmazonSQSAsyncClient

List of usage examples for com.amazonaws.services.sqs AmazonSQSAsyncClient AmazonSQSAsyncClient

Introduction

In this page you can find the example usage for com.amazonaws.services.sqs AmazonSQSAsyncClient AmazonSQSAsyncClient.

Prototype

AmazonSQSAsyncClient(AwsAsyncClientParams asyncClientParams) 

Source Link

Document

Constructs a new asynchronous client to invoke service methods on Amazon SQS using the specified parameters.

Usage

From source file:com.aipo.aws.sqs.SQS.java

License:Open Source License

public static AmazonSQSAsync getAsyncClient() {
    AWSContext awsContext = AWSContext.get();
    if (awsContext == null) {
        throw new IllegalStateException("AWSContext is not initialized.");
    }/* w w  w .  j  a v  a2  s  .  c  o  m*/
    AmazonSQSAsync client = new AmazonSQSAsyncClient(awsContext.getAwsCredentials());
    String endpoint = awsContext.getSqsEndpoint();
    if (endpoint != null && endpoint != "") {
        client.setEndpoint(endpoint);
    }
    return client;
}

From source file:net.smartcosmos.plugin.service.aws.queue.AwsQueueService.java

License:Apache License

@Override
public void initialize() {
    super.initialize();

    if (!exists(DEFAULT_QUEUE_NAME)) {
        create(DEFAULT_QUEUE_NAME);//from  w  w w. ja  va  2 s . c  o m
    }

    String queueName = context.getConfiguration().getServiceParameters()
            .get(SERVICE_PARAM_QUEUE_SERVICE_QUEUE_NAME);

    if (queueName != null & !exists(queueName)) {
        create(queueName);
    }
    sqsAsyncClient = new AmazonSQSAsyncClient(credentials);
}

From source file:org.apache.usergrid.apm.service.ServiceFactory.java

License:Apache License

public static AmazonSQSAsyncClient getSQSAsyncClient() {
    if (sqsAsyncClient == null) {
        DeploymentConfig config = DeploymentConfig.geDeploymentConfig();
        AWSCredentials awsCredentials = new BasicAWSCredentials(config.getAccessKey(), config.getSecretKey());
        sqsAsyncClient = new AmazonSQSAsyncClient(awsCredentials);
    }//from  w  w  w  . ja  v a 2 s  . c o m

    return sqsAsyncClient;
}

From source file:org.cloudml.connectors.BeanstalkConnector.java

License:Open Source License

public BeanstalkConnector(String login, String pass, String region) {
    awsCredentials = new BasicAWSCredentials(login, pass);
    beanstalkClient = new AWSElasticBeanstalkClient(awsCredentials);
    this.beanstalkEndpoint = String.format("elasticbeanstalk.%s.amazonaws.com", region);
    beanstalkClient.setEndpoint(beanstalkEndpoint);

    this.rdsEndpoint = String.format("rds.%s.amazonaws.com", region);
    rdsClient = new AmazonRDSClient(awsCredentials);
    rdsClient.setEndpoint(rdsEndpoint);/*from  w w w.  jav a 2  s.c o m*/

    this.sqsEndpoint = String.format("sqs.%s.amazonaws.com", region);
    sqsClient = new AmazonSQSAsyncClient(awsCredentials);
    sqsClient.setEndpoint(this.sqsEndpoint);
}

From source file:org.elasticsearch.river.amazonsqs.AmazonsqsRiver.java

License:Apache License

@SuppressWarnings({ "unchecked" })

@Inject/*from   ww w  .j a v  a 2  s .c  o  m*/
public AmazonsqsRiver(RiverName riverName, RiverSettings settings, Client client) {
    super(riverName, settings);
    this.client = client;

    if (settings.settings().containsKey("amazonsqs")) {
        Map<String, Object> sqsSettings = (Map<String, Object>) settings.settings().get("amazonsqs");

        REGION = XContentMapValues.nodeStringValue(sqsSettings.get("region"), "null");
        ACCESSKEY = XContentMapValues.nodeStringValue(sqsSettings.get("accesskey"), "null");
        SECRETKEY = XContentMapValues.nodeStringValue(sqsSettings.get("secretkey"), "null");
        QUEUE_URL = XContentMapValues.nodeStringValue(sqsSettings.get("queue_url"), "null");

    } else {
        REGION = settings.globalSettings().get("cloud.aws.region");
        ACCESSKEY = settings.globalSettings().get("cloud.aws.access_key");
        SECRETKEY = settings.globalSettings().get("cloud.aws.secret_key");
        QUEUE_URL = settings.globalSettings().get("cloud.aws.sqs.queue_url");

    }

    if (settings.settings().containsKey("index")) {
        Map<String, Object> indexSettings = (Map<String, Object>) settings.settings().get("index");
        INDEX = XContentMapValues.nodeStringValue(indexSettings.get("index"), "elasticsearch");
        MAX_MESSAGES = XContentMapValues.nodeIntegerValue(indexSettings.get("max_messages"), 10);
        TIMEOUT = XContentMapValues.nodeIntegerValue(indexSettings.get("timeout_seconds"), 10);
    } else {
        INDEX = settings.globalSettings().get("cluster.name");
        MAX_MESSAGES = 10;
        TIMEOUT = 10;
    }

    sqs = new AmazonSQSAsyncClient(new BasicAWSCredentials(ACCESSKEY, SECRETKEY));
    sqs.setEndpoint("https://".concat(REGION).concat(".queue.amazonaws.com"));
    mapper = new ObjectMapper();
}

From source file:org.springframework.cloud.aws.messaging.config.annotation.SqsClientConfiguration.java

License:Apache License

@Lazy
@Bean(destroyMethod = "shutdown")
public AmazonSQSAsync amazonSQS() {
    AmazonSQSAsyncClient amazonSQSAsyncClient;
    if (this.awsCredentialsProvider != null) {
        amazonSQSAsyncClient = new AmazonSQSAsyncClient(this.awsCredentialsProvider);
    } else {//from  ww  w  .jav a 2 s  .co  m
        amazonSQSAsyncClient = new AmazonSQSAsyncClient();
    }

    if (this.regionProvider != null) {
        amazonSQSAsyncClient.setRegion(this.regionProvider.getRegion());
    }

    return new AmazonSQSBufferedAsyncClient(amazonSQSAsyncClient);
}