Thursday, April 8, 2010

First impressions of Amazon Simple Notification Service

Amazon introduced their new Simple Notification Service (SNS) earlier this week and with a background and interest in integration and messaging I had to take a look.

The sign-up process is simple enough and I added access to it from my existing Amazon Web Services account and was pleased to see that current pricing includes a Free Tier that provides 100K requests and notifications (1K e-mail notifications) for free.  With that, I launched into the getting started guide.

I downloaded the CLI (minor nit, the guide gave the wrong pointer to where to download it, but was easily found), already had Java installed, so I set the required environment variables and was off an running.  There was a mention that the CLI was for Windows and Linux, but I forged ahead on my Mac figuring it would just work, and thankfully it did.

I followed the guide to create a topic, subscribe to it using e-mail, publish a message, and get the notification.  It all worked very nicely and as one would expect.  So, it works, but using a command line tool to send myself an e-mail isn't terribly useful or interesting and if that is all I did, this would be a pretty boring blog entry!  How about something more interesting then?

I have a weather station set up at home along with a web-site for viewing the current weather and uploading historical data to the Weather Underground.  I find myself checking the current conditions periodically, but polling for that kind of thing is a bit cumbersome.  It seems like having a notification pushed to me when certain conditions occur might be more useful and enter SNS to help solve that for me.

So, I wrote a script that I have cron run every 10 minutes that checks the temperature and pressure and if the change is greater than a certain threshold, publishes a notification to my "Weather" topic.  I'm then able to subscribe to the topic so that I'm sent an SMS when a weather notification is published.  Using SNS, I was able to set this up in a matter of minutes and now have something that will just run for me from now on.  Note that I did this on Linux as that is what is running on the machine my weather station is connected to so indeed it does work on both OS X and Linux.

One might ask, why use SNS to do the notification when I could have just had my script do it?  Great question, and if my only goal was to do just this notification for just myself, just hardcoding it in the script would be fine.  But using SNS decouples the components of the application that gives more flexibility and allows the consuming services to be independent of the producer.  It enables new styles of programming centered around asynchronous messaging.

For example, what if others want to also get the notification?  Or if rather than just sending an e-mail I'd like to have a consuming service log the notifications or perform some other processing on the data?  By using SNS to decouple the services, this is easily possible by simply adding subscriptions for each new consumer and I can avoid having to modify or maintain my script with details it really shouldn't be concerned with.

With SNS Amazon has a nice complement to the Simple Queue Service (SQS) that has been around for a little while.  Interested in learning more about asynchronous messaging?  Give one or both a try.

1 comment:

  1. Hi, this is Jeff D Marsh Amazon Listing Service, Amazon listing india, Amazon product entry services, Online product entry amazon, Amazon Listing company, Amazon product entry, Amazon inventory listing, Amazon bulk listing, amazon Data Entry, data entry for Amazon, Amazon Product Upload, Amazon Products Bulk Listing, Affordable Amazon service, Inventory Management at Amazon, Uk, USA, Australia, Canada
    To have better idea about the same just click on the link given hereby at
    I like your information it is helpful to me.