io.pythagoras.messagebus.adapter.awssnssqs.SNSClientProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of adapter-sqs-sns Show documentation
Show all versions of adapter-sqs-sns Show documentation
Pythagoras SQS/SNS Adapter for Message Bus
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