curena
9/2/2015 - 8:46 PM

Create SNS Topic

Create SNS Topic

//create a new SNS client and set endpoint
AmazonSNSClient snsClient = new AmazonSNSClient(new ClasspathPropertiesFileCredentialsProvider());		                           
snsClient.setRegion(Region.getRegion(Regions.US_EAST_1));

//create a new SNS topic
CreateTopicRequest createTopicRequest = new CreateTopicRequest("MyNewTopic");
CreateTopicResult createTopicResult = snsClient.createTopic(createTopicRequest);
//print TopicArn
System.out.println(createTopicResult);
//get request id for CreateTopicRequest from SNS metadata		
System.out.println("CreateTopicRequest - " + snsClient.getCachedResponseMetadata(createTopicRequest));