List of usage examples for com.amazonaws.services.sns AmazonSNSClient builder
public static AmazonSNSClientBuilder builder()
From source file:org.smap.notifications.interfaces.EmitDeviceNotification.java
License:Open Source License
public EmitDeviceNotification() { // get properties file try {//from w ww . j a v a 2 s . c o m properties.load(new FileInputStream("/smap_bin/resources/properties/aws.properties")); tableName = properties.getProperty("userDevices_table"); region = properties.getProperty("userDevices_region"); platformApplicationArn = properties.getProperty("fieldTask_platform"); } catch (Exception e) { log.log(Level.SEVERE, "Error reading properties", e); } //create a new DynamoDB client dynamoDB = AmazonDynamoDBClient.builder().withRegion(region) .withCredentials(new ProfileCredentialsProvider()).build(); //create a new SNS client AmazonSNS sns = AmazonSNSClient.builder().withRegion(region) .withCredentials(new ProfileCredentialsProvider()).build(); // create a wraper snsClientWrapper = new AmazonSNSClientWrapper(sns); }
From source file:org.smap.notifications.interfaces.EmitNotifications.java
License:Open Source License
public void publish(int event, String msg, String subject) { //create a new SNS client AmazonSNS sns = AmazonSNSClient.builder().withRegion("ap-southeast-1") .withCredentials(new ClasspathPropertiesFileCredentialsProvider()).build(); String topic = getTopic(event); if (topic != null) { PublishRequest publishRequest = new PublishRequest(topic, msg, subject); PublishResult publishResult = sns.publish(publishRequest); log.info("Publish: " + subject + " MessageId - " + publishResult.getMessageId()); }/*from w w w . java 2 s . com*/ }
From source file:org.thingsboard.rule.engine.aws.sns.TbSnsNode.java
License:Apache License
@Override public void init(TbContext ctx, TbNodeConfiguration configuration) throws TbNodeException { this.config = TbNodeUtils.convert(configuration, TbSnsNodeConfiguration.class); AWSCredentials awsCredentials = new BasicAWSCredentials(this.config.getAccessKeyId(), this.config.getSecretAccessKey()); AWSStaticCredentialsProvider credProvider = new AWSStaticCredentialsProvider(awsCredentials); try {//from w w w . j av a 2s . c o m this.snsClient = AmazonSNSClient.builder().withCredentials(credProvider) .withRegion(this.config.getRegion()).build(); } catch (Exception e) { throw new TbNodeException(e); } }
From source file:org.thingsboard.server.extensions.sns.plugin.SnsPlugin.java
License:Apache License
private void init() { AWSCredentials awsCredentials = new BasicAWSCredentials(configuration.getAccessKeyId(), configuration.getSecretAccessKey()); AWSStaticCredentialsProvider credProvider = new AWSStaticCredentialsProvider(awsCredentials); AmazonSNS sns = AmazonSNSClient.builder().withCredentials(credProvider) .withRegion(configuration.getRegion()).build(); this.snsMessageHandler = new SnsMessageHandler(sns); }