com.tuprofe.api.SQSConfig.java Source code

Java tutorial

Introduction

Here is the source code for com.tuprofe.api.SQSConfig.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.tuprofe.api;

import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.sqs.AmazonSQS;
import com.amazonaws.services.sqs.AmazonSQSClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

/**
 *
 * @author diego
 */
@Configuration
@PropertySource(value = "classpath:aws-config.properties")
public class SQSConfig {

    @Value("${amazon.aws.accesskey}")
    private String amazonAWSAccessKey;

    @Value("${amazon.aws.secretkey}")
    private String amazonAWSSecretKey;

    @Bean
    public BasicAWSCredentials basicAWSCredentials() {
        return new BasicAWSCredentials(amazonAWSAccessKey, amazonAWSSecretKey);
    }

    @Bean
    public AmazonSQS amazonSQSClient() {
        AmazonSQS amazonSQS = new AmazonSQSClient(basicAWSCredentials());
        amazonSQS.setRegion(Region.getRegion(Regions.US_WEST_2));
        return amazonSQS;
    }
}