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

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

Introduction

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

Prototype

@Deprecated
public AmazonSQSClient() 

Source Link

Document

Constructs a new client to invoke service methods on Amazon SQS.

Usage

From source file:com.blacklocus.qs.worker.aws.AmazonSQSTaskService.java

License:Apache License

public AmazonSQSTaskService(String queueUrl) {
    this(queueUrl, new AmazonSQSClient());
}

From source file:com.dushyant.flume.sink.aws.sqs.BasicSQSMsgSender.java

License:Apache License

public BasicSQSMsgSender(String sqsUrl, String region, String awsAccessKey, String awsSecretKey) {
    this.sqsUrl = sqsUrl;
    this.region = region;
    this.awsAccessKey = awsAccessKey;
    this.awsSecretKey = awsSecretKey;

    AmazonSQS sqs = null;//from  ww w.j ava 2  s  . com
    if (StringUtils.isBlank(awsAccessKey) || StringUtils.isBlank(awsSecretKey)) {
        LOG.warn(
                "Either awsAccessKey or awsSecretKey not specified. Will use DefaultAWSCredentialsProviderChain "
                        + "to look for AWS credentials.");
        sqs = new AmazonSQSClient();
    } else {
        sqs = new AmazonSQSClient(new BasicAWSCredentials(this.awsAccessKey, this.awsSecretKey));
    }

    Region sqsRegion = Region.getRegion(Regions.fromName(this.region));
    sqs.setRegion(sqsRegion);

    this.amazonSQS = sqs;
}

From source file:com.dushyant.flume.sink.aws.sqs.BatchSQSMsgSender.java

License:Apache License

public BatchSQSMsgSender(String sqsUrl, String region, String awsAccessKey, String awsSecretKey, int batchSize,
        long maxMessageSize) {
    this.sqsUrl = sqsUrl;
    this.region = region;
    this.awsAccessKey = awsAccessKey;
    this.awsSecretKey = awsSecretKey;

    AmazonSQS sqs = null;/*from   w  w w.j  ava  2  s .c om*/
    if (StringUtils.isBlank(awsAccessKey) || StringUtils.isBlank(awsSecretKey)) {
        LOG.warn(
                "Either awsAccessKey or awsSecretKey not specified. Will use DefaultAWSCredentialsProviderChain "
                        + "to look for AWS credentials.");
        sqs = new AmazonSQSClient();
    } else {
        sqs = new AmazonSQSClient(new BasicAWSCredentials(this.awsAccessKey, this.awsSecretKey));
    }

    Region sqsRegion = Region.getRegion(Regions.fromName(this.region));
    sqs.setRegion(sqsRegion);

    this.batchSize = batchSize;
    this.maxMessageSize = maxMessageSize;

    this.amazonSQS = sqs;
}

From source file:com.github.abhinavmishra14.aws.glacier.service.impl.GlacierArchiveServiceImpl.java

License:Open Source License

/**
 * The Constructor.<b/>//from   ww w. j a v  a  2 s.  co  m
 * This Constructor will return glacier client if IAM role is enabled.<br/>
 * Additionally it will set the given endPoint for performing upload operation over vault.<br/>
 * Default endpoint will be always: "https://glacier.us-east-1.amazonaws.com/"
 * SSL Certificate checking will be disabled based on provided flag.
 *
 * @param disableCertCheck the disable cert check
 * @param endpoint the endpoint
 */
public GlacierArchiveServiceImpl(final boolean disableCertCheck, final String endpoint) {
    super();
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("GlacierArchiveServiceImpl is initializing using IAM Role..");
    }
    glacierClient = new AmazonGlacierClient(); //Get IAM Based glacier client
    sqsClient = new AmazonSQSClient();
    snsClient = new AmazonSNSClient();
    if (disableCertCheck) {
        System.setProperty(DISABLE_CERT_PARAM, TRUE);//Disable cert check
    }
    if (StringUtils.isNotBlank(endpoint)) {
        glacierClient.setEndpoint(endpoint);
    }
}

From source file:doug.iotdemo.analyzer.Analyzer.java

License:Open Source License

void run() throws IOException, MqttException {
    System.out.println("Doing initial scan");
    doInitialScan();//  w w  w .jav  a2 s  . co m
    System.out.println("Done");

    String url = AmazonUtils.getTimeQueueURL();
    AmazonSQS sqs = new AmazonSQSClient();
    while (true) {
        ReceiveMessageResult msgResult = sqs.receiveMessage(url);
        for (Message msg : msgResult.getMessages()) {
            JsonObject request = new JsonParser().parse(msg.getBody()).getAsJsonObject();
            String sensor = request.get("sensor").getAsString();
            long time = request.get("time").getAsLong();
            addTime(sensor, time);
            saveSensor(sensor);
            sqs.deleteMessage(url, msg.getReceiptHandle());
        }
    }
}

From source file:doug.iotdemo.lambda.sensor.SensorLambda.java

License:Open Source License

private void handleTime(JsonObject request) throws IOException {
    Map<String, AttributeValue> item = new HashMap<>();
    item.put("sensor", new AttributeValue().withS(request.get("sensor").getAsString()));
    item.put("timestamp", new AttributeValue().withN(Long.toString(System.currentTimeMillis())));
    item.put("time", new AttributeValue().withN(Integer.toString(request.get("time").getAsInt())));
    db.putItem(AmazonUtils.getTimeTableName(), item);
    System.out.println("Item writen to TimeTable");

    AmazonSQS sqs = new AmazonSQSClient();
    String url = AmazonUtils.getTimeQueueURL();
    sqs.sendMessage(new SendMessageRequest(url, new Gson().toJson(request)));
    System.out.println("SQS Message sent to " + url);
}

From source file:pl.worker.Main.java

public static String getMessage(String url) {
    final AmazonSQS sqsClient = new AmazonSQSClient();
    final ReceiveMessageRequest request = new ReceiveMessageRequest(url);
    request.setMaxNumberOfMessages(1);//from  ww w  .j a  v a2 s. co m
    ReceiveMessageResult result = sqsClient.receiveMessage(request);
    List<Message> messages = result.getMessages();
    if (messages.isEmpty()) {
        return null;
    }
    String body = messages.get(0).getBody();
    sqsClient.deleteMessage(url, messages.get(0).getReceiptHandle());
    return body;
}

From source file:se.symsoft.codecamp.SmsGeneratorService.java

License:Open Source License

private HttpServer start() throws IOException {
    AmazonDynamoDBClient amazonDynamoDBClient = new AmazonDynamoDBClient().withRegion(Regions.EU_WEST_1);
    dynamoDB = new DynamoDBMapper(amazonDynamoDBClient);

    sqsClient = new AmazonSQSClient().withRegion(Regions.EU_WEST_1);
    String queueName = System.getenv("SQS_QUEUE_NAME");
    System.out.println("SQS_QUEUE_NAME = " + queueName);
    GetQueueUrlResult result = sqsClient.getQueueUrl(queueName);
    queueUrl = result.getQueueUrl();/*from  w ww.  j  a  va 2  s.  c  o m*/
    SqsMessageReceiver sqsMessageReceiver = new SqsMessageReceiver(this, sqsClient, queueName);
    new Thread(sqsMessageReceiver).start();

    Metrics.startGraphiteMetricsReporter();

    URI baseUri = UriBuilder.fromUri("http://0.0.0.0/").port(8070).build();

    HttpServer server = GrizzlyHttpServerFactory.createHttpServer(baseUri, this);
    server.getServerConfiguration().addHttpHandler(
            new CLStaticHttpHandler(SmsGeneratorService.class.getClassLoader(), "web/"), "/generator-ui");
    server.start();
    return server;
}