com.amazonaws.services.sns.AmazonSNSAsync Java Examples

The following examples show how to use com.amazonaws.services.sns.AmazonSNSAsync. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SnsConfiguration.java    From data-highway with Apache License 2.0 7 votes vote down vote up
@Bean
public AmazonSNSAsync snsClient(
    @Value("${notification.sns.region}") String region,
    @Value("${notification.sns.endpointUrl:disabled}") String snsEndpointUrl) {
  if ("disabled".equalsIgnoreCase(snsEndpointUrl)) {
    return null;
  }
  AmazonSNSAsync client = AmazonSNSAsyncClientBuilder
      .standard()
      .withClientConfiguration(
          new ClientConfiguration().withRetryPolicy(PredefinedRetryPolicies.getDefaultRetryPolicy()))
      .withExecutorFactory(() -> Executors.newSingleThreadScheduledExecutor())
      .withEndpointConfiguration(new EndpointConfiguration(snsEndpointUrl, region))
      .build();
  return client;
}
 
Example #2
Source File: AwsMetricsPublisher.java    From bazel-buildfarm with Apache License 2.0 6 votes vote down vote up
private AmazonSNSAsync initSnsClient() {
  logger.log(Level.INFO, "Initializing SNS Client.");
  return AmazonSNSAsyncClientBuilder.standard()
      .withRegion(region)
      .withClientConfiguration(
          new ClientConfiguration().withMaxConnections(snsClientMaxConnections))
      .withCredentials(
          new AWSStaticCredentialsProvider(
              new AWSCredentials() {
                @Override
                public String getAWSAccessKeyId() {
                  return awsAccessKeyId;
                }

                @Override
                public String getAWSSecretKey() {
                  return awsSecretKey;
                }
              }))
      .build();
}
 
Example #3
Source File: SnsNotificationSender.java    From data-highway with Apache License 2.0 5 votes vote down vote up
public SnsNotificationSender(AmazonSNSAsync sns, TopicArnFactory topicArnFactory, MessageFactory messageFactory) {
  log.info("Starting SNS notifier.");
  this.sns = sns;
  this.topicArnFactory = topicArnFactory;
  this.messageFactory = messageFactory;
  ObjectMapper mapper = new ObjectMapper();
  mapper.setSerializationInclusion(Include.NON_NULL);
  objectWriter = mapper.writer();
}
 
Example #4
Source File: SnsConfiguration.java    From data-highway with Apache License 2.0 5 votes vote down vote up
@Bean
public NotificationSender snsNotificationSender(
    AmazonSNSAsync sns,
    @Value("${notification.sns.topicArnFormat:disabled}") String topicArnFormat) {
  if (sns == null || topicArnFormat == null || "disabled".equalsIgnoreCase(topicArnFormat)) {
    log.info("Data Highway notifications are disabled. (SNS client is: {}, SNS topic is: {})", sns, topicArnFormat);
    return NotificationSender.nullObject;
  }
  return new SnsNotificationSender(sns, n -> String.format(topicArnFormat, n.getRoadName()),
      (t, n) -> String.format("Data Highway Notification for road '%s'.", n.getRoadName()));
}
 
Example #5
Source File: AmazonAsyncDockerClientsHolder.java    From spring-localstack with Apache License 2.0 5 votes vote down vote up
@Override
public AmazonSNSAsync amazonSNS() {
    return decorateWithConfigsAndBuild(
        AmazonSNSAsyncClientBuilder.standard(),
        LocalstackDocker::getEndpointSNS
    );
}
 
Example #6
Source File: SnsListener.java    From circus-train with Apache License 2.0 5 votes vote down vote up
SnsListener(AmazonSNSAsync sns, ListenerConfig config, Clock clock) {
  this.clock = clock;
  LOG
      .info("Starting listener, topics: start={}, success={}, fail={}", config.getStartTopic(),
          config.getSuccessTopic(), config.getFailTopic());
  this.sns = sns;
  this.config = config;
  ObjectMapper mapper = new ObjectMapper();
  mapper.setSerializationInclusion(Include.NON_NULL);
  startWriter = mapper.writer();
}
 
Example #7
Source File: SnsConfiguration.java    From circus-train with Apache License 2.0 5 votes vote down vote up
@Bean
AmazonSNSAsync amazonSNS(ListenerConfig config, AWSCredentialsProvider awsCredentialsProvider) {
  return AmazonSNSAsyncClient.asyncBuilder()
      .withCredentials(awsCredentialsProvider)
      .withRegion(config.getRegion())
      .build();
}
 
Example #8
Source File: SnsListener.java    From circus-train with Apache License 2.0 4 votes vote down vote up
@Autowired
public SnsListener(AmazonSNSAsync sns, ListenerConfig config) {
  this(sns, config, Clock.DEFAULT);
}