Example usage for com.amazonaws.services.sns AmazonSNSClient publish

List of usage examples for com.amazonaws.services.sns AmazonSNSClient publish

Introduction

In this page you can find the example usage for com.amazonaws.services.sns AmazonSNSClient publish.

Prototype

@Override
    public PublishResult publish(String topicArn, String message, String subject) 

Source Link

Usage

From source file:com.nextdoor.bender.handler.s3.SNSS3Handler.java

License:Apache License

@Override
public void onException(Exception e) {
    /*/*ww w. j  a v  a 2 s  .  com*/
     * Always close the iterator to prevent connection leaking
     */
    try {
        if (this.recordIterator != null) {
            this.recordIterator.close();
        }
    } catch (IOException e1) {
        logger.error("unable to close record iterator", e);
    }

    if (this.config == null || this.config.getHandlerConfig() == null) {
        return;
    }

    /*
     * Notify SNS topic
     */
    SNSS3HandlerConfig handlerConfig = (SNSS3HandlerConfig) this.config.getHandlerConfig();
    if (handlerConfig.getSnsNotificationArn() != null) {
        AmazonSNSClient snsClient = this.snsClientFactory.newInstance();
        snsClient.publish(handlerConfig.getSnsNotificationArn(),
                this.inputFiles.stream().map(Object::toString).collect(Collectors.joining(",")),
                "SNSS3Handler Failed");
    }
}

From source file:com.nextdoor.bender.S3SnsNotifier.java

License:Apache License

public static boolean publish(String arn, String msg, AmazonSNSClient snsClient, String s3Key) {
    if (dryRun) {
        logger.warn("would have published " + s3Key + " S3 creation event to SNS");
        return true;
    }/*from w  w w. j a  v a  2  s.c  o m*/

    logger.info("publishing " + s3Key + " S3 creation event to SNS");

    try {
        snsClient.publish(arn, msg, "Amazon S3 Notification");
    } catch (RuntimeException e) {
        logger.error("error publishing", e);
        return false;
    }

    return true;
}