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

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

Introduction

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

Prototype

PublishResult publish(String topicArn, String message);

Source Link

Document

Simplified method form for invoking the Publish operation.

Usage

From source file:ca.paullalonde.gocd.sns_plugin.executors.StageStatusRequestExecutor.java

License:Apache License

protected void sendNotification() throws Exception {
    PluginSettings pluginSettings = pluginRequest.getPluginSettings();
    String topic = pluginSettings.getTopic();

    if ((topic != null) && !topic.isEmpty()) {
        AmazonSNS sns = makeSns(pluginSettings);
        try {/*from w ww .j  a v a 2s .c o  m*/
            sns.publish(topic, request.toJSON());
        } catch (AmazonServiceException e) {
            String message = String.format(
                    "StageStatusRequestExecutor : Cannot publish to SNS topic, error code = '%s', message = '%s'.",
                    e.getErrorCode(), e.getErrorMessage());
            LOG.error(message);
        } catch (AmazonClientException e) {
            String message = String.format(
                    "StageStatusRequestExecutor : Cannot publish to SNS topic, message = '%s'.",
                    e.getMessage());
            LOG.error(message);
        }
    } else {
        LOG.debug("StageStatusRequestExecutor : Cannot publish to SNS because the topic is missing.");
    }
}