Testing and querying the configuration - Amazon Simple Notification Service
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Testing and querying the configuration

This page describes how to test the message archiving and analytics example use case by publishing a message to the Amazon SNS topic. The instructions include an example query that you can run and adapt to your own needs.

To test your configuration
  1. Open the Topics page of the Amazon SNS console.

  2. Choose the ticketTopic topic.

  3. Choose Publish message.

  4. On the Publish message to topic page, enter the following for the message body. Add a newline character at the end of the message.

    {"BookingDate":"2020-12-15","BookingTime":"2020-12-15 04:15:05","Destination":"Miami","FlyingFrom":"Vancouver","TicketNumber":"abcd1234"}

    Keep all other options as their defaults.

  5. Choose Publish message.

    For more information on publishing messages, see Amazon SNS message publishing.

  6. After the delivery stream interval of 60 seconds, open the Amazon Simple Storage Service (Amazon S3) console and choose the Amazon S3 bucket that you created initially.

    The published message appears in the bucket.

To query the data
  1. Open the Amazon Athena console.

  2. Run a query.

    For example, assume that the notifications table in the default schema contains the following data:

    {"BookingDate":"2020-12-15","BookingTime":"2020-12-15 04:15:05","Destination":"Miami","FlyingFrom":"Vancouver","TicketNumber":"abcd1234"} {"BookingDate":"2020-12-15","BookingTime":"2020-12-15 11:30:15","Destination":"Miami","FlyingFrom":"Omaha","TicketNumber":"efgh5678"} {"BookingDate":"2020-12-15","BookingTime":"2020-12-15 3:30:10","Destination":"Miami","FlyingFrom":"NewYork","TicketNumber":"ijkl9012"} {"BookingDate":"2020-12-15","BookingTime":"2020-12-15 12:30:05","Destination":"Delhi","FlyingFrom":"Omaha","TicketNumber":"mnop3456"}

    To find the top destination, run the following query:

    SELECT destination FROM default.notifications GROUP BY destination ORDER BY count(*) desc LIMIT 1;

    To query for tickets sold during a specific date and time range, run a query like the following:

    SELECT * FROM default.notifications WHERE bookingtime BETWEEN TIMESTAMP '2020-12-15 10:00:00' AND TIMESTAMP '2020-12-15 12:00:00';

    You can adapt both sample queries for your own needs. For more information on using Athena to run queries, see Getting Started in the Amazon Athena User Guide.

Cleaning up

To avoid incurring usage charges after you're done testing, delete the following resources that you created during the tutorial:

  • Amazon SNS subscriptions

  • Amazon SNS topic

  • Amazon Simple Queue Service (Amazon SQS) queues

  • Amazon S3 bucket

  • Amazon Data Firehose delivery stream

  • Amazon Identity and Access Management (IAM) roles and policies