Example usage for com.amazonaws.services.sns.model CreateTopicRequest withName

List of usage examples for com.amazonaws.services.sns.model CreateTopicRequest withName

Introduction

In this page you can find the example usage for com.amazonaws.services.sns.model CreateTopicRequest withName.

Prototype


public CreateTopicRequest withName(String name) 

Source Link

Document

The name of the topic you want to create.

Usage

From source file:com.connexience.server.model.archive.glacier.SetupUtils.java

License:Open Source License

public static String setupSNS(String accessKey, String secretKey, String domainName, String vaultName,
        String queueARN) {// ww w  .  java  2 s .  com
    String topicARN = null;
    try {
        AWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretKey);

        AmazonSNSClient amazonSNSClient = new AmazonSNSClient(awsCredentials);
        amazonSNSClient.setEndpoint("https://sns." + domainName + ".amazonaws.com/");

        String topicName = vaultName + "-inkspot_glacier-topic";
        CreateTopicRequest createTopicRequest = new CreateTopicRequest();
        createTopicRequest.withName(topicName);

        CreateTopicResult createTopicResult = amazonSNSClient.createTopic(createTopicRequest);
        if (createTopicResult != null) {
            topicARN = createTopicResult.getTopicArn();

            SubscribeRequest subscribeRequest = new SubscribeRequest();
            subscribeRequest.withTopicArn(topicARN);
            subscribeRequest.withProtocol("sqs");
            subscribeRequest.withEndpoint(queueARN);

            SubscribeResult subscribeResult = amazonSNSClient.subscribe(subscribeRequest);
            if (subscribeResult == null)
                logger.warn("Unable to subscribe topic: \"" + topicName + "\" to queue: \"" + queueARN + "\"");
        } else
            logger.warn("Unable to create topic: \"" + topicName + "\"");

        amazonSNSClient.shutdown();
    } catch (AmazonServiceException amazonServiceException) {
        logger.warn("AmazonServiceException: " + amazonServiceException);
        logger.debug(amazonServiceException);
    } catch (IllegalArgumentException illegalArgumentException) {
        logger.warn("IllegalArgumentException: " + illegalArgumentException);
        logger.debug(illegalArgumentException);
    } catch (AmazonClientException amazonClientException) {
        logger.warn("AmazonClientException: " + amazonClientException);
        logger.debug(amazonClientException);
    } catch (Throwable throwable) {
        logger.warn("Throwable: " + throwable);
        logger.debug(throwable);
    }

    return topicARN;
}

From source file:com.screensaver.util.AmazonSNSClientWrapper.java

License:Open Source License

private CreateTopicResult createTopic(Platform platform, String s, String platformToken,
        String platformApplicationArn) {
    CreateTopicRequest createTopicRequest = new CreateTopicRequest();
    createTopicRequest.withName(Constants.SNS_TOPIC);
    return snsClient.createTopic(createTopicRequest);

}