All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.pythagoras.messagebus.adapter.awssnssqs.SNSClientProvider Maven / Gradle / Ivy

There is a newer version: 1.8.3
Show newest version
package io.pythagoras.messagebus.adapter.awssnssqs;

import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.services.sns.AmazonSNS;
import com.amazonaws.services.sns.AmazonSNSClientBuilder;
import com.amazonaws.services.sqs.AmazonSQSClientBuilder;
import io.pythagoras.messagebus.adapter.awssnssqs.config.Properties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SNSClientProvider {

    private CredentialsProvider credentialsProvider;

    private Properties properties;

    private AmazonSNS sns;

    @Autowired
    public void setCredentialsProvider(CredentialsProvider credentialsProvider) {
        this.credentialsProvider = credentialsProvider;
    }

    @Autowired
    public void setProperties(Properties properties) {
        this.properties = properties;
    }

    public AmazonSNS getSyncClient() {
        if(sns == null) {
            this.sns = AmazonSNSClientBuilder.standard()
                    .withCredentials(new AWSStaticCredentialsProvider(credentialsProvider.getCredentials()))
                    .withRegion(properties.getRegion())
                    .build();
        }
        return sns;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy