This example shows you how to durably subscribe to messages from an AWS Simple Notification Service topic.
The example creates an SNS topic that is consumed and stored by an SQS queue. This allows the subscriber to read the events from SNS off of the SQS queue where they are durably stored. The subscriber need not worry about message loss in the case of a disconnect because the SQS queue is storing the notifications.
The example requires that you create an SNS topic and an SQS queue in your AWS account using the following CloudFormation template:
The example can be run using the following gradle command:
$ ./gradlew run -DtopicArn={sns topic arn} -DqueueArn={sqs queue arn}
NOTE: The example is using the DefaultAWSCredentialsProvider
so you can supply your AWS credentials using the .aws/credentials
file, as system properties, or as environment variables.
Copyright 2016 Greg Whitaker
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.