The purpose of this snippet is to show how to create a route that sends SNS to amazon using Camel and how to configure amazon in order to send a SMS each time a SNS is received.

First you must link the camel libraries in order to use amazon SNS. See this previous post if you are not comfortable with this process.

Add the following lines in your pom file:

<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-aws</artifactId>
  <version>${camel.version}</version>
</dependency>

We are using the version 2.18 of Camel that lets you specify the arn address.

Next you must add a route that triggers SNS as shown below:

<route>
  <from uri="timer://pubsubid?fixedRate=true&amp;period=5000"/>
  <setBody>
    <simple>Hello world !</simple>
  </setBody>
  <removeHeaders pattern="*"/>
  <to uri="aws-sns:arn:aws:sns:us-west-2:XXXXXXXXXXX:testalert?accessKey=YYYYYYYYYYY&amp;secretKey=ZZZZZZZZZZZZ&amp;amazonSNSEndpoint=sns.us-west-2.amazonaws.com"/>
  <to uri="log:MESSAGE?showAll=true"/>
</route>

In order to get your arn address, fire up the SNS console from amazon as shown in the next picture.

screen-shot-2016-10-17-at-21-39-50

Create a SMS subscription to your topic as shown below.

screen-shot-2016-10-17-at-21-45-03

Don’t forget to add a user and the ad hoc policy in the IAM console of amazon.

screen-shot-2016-10-17-at-21-47-35