Amazon has just come out with yet another service to help build your app on AWS. Their Simple Notification Service is a pub/sub setup where you create topics and users can subscribe. Delivery is via a “push” mechanism, so subscribers won’t need to poll for new messages. Output can be one of several protocols which include http/https/email/email-json or sqs. While the e-mail output can be useful for managing things like users watching a comment or blog post. The other options are clearly geared towards consumption by other software. Imagine the http options being used to implement a web service callback. SQS is clearly helpful for building loosely coupled services in the cloud. Now, SNS can help feed into those services.
typica now supports SNS. Subversion contains the latest code. A release will be coming shortly. (check this space for updates)
Here’s an example of how to use typica to create a topic, subscribe, send a message, then unsubscribe and remove the topic;
NotificationService sns = new NotificationService(props.getProperty("aws.accessId"), props.getProperty("aws.secretKey")); Result<String> ret = sns.createTopic("TestTopic"); String topicArn = ret.getResult(); System.err.println("topicArn: "+topicArn); sns.subscribe(topicArn, "email", "firstname.lastname@example.org"); System.out.println("Waiting till subscription is confirmed."); System.out.println("Check your e-mail, confirm, then press <return>"); System.in.read(); List<SubscriptionInfo> subs = sns.listSubscriptionsByTopic(topicArn, null).getItems(); String subArn = subs.get(0).getSubscriptionArn(); System.err.println("subscriptionArn: "+subArn); sns.publish(topicArn, TEST_MSG, "[SNS] testing..."); sns.unsubscribe(subArn); sns.deleteTopic(topicArn);