Photo Status Queues (via AWS SQS or SNS)

Statues queues allow organizations to send photo information messages to AWS Simple Queue Service to be processed by external integrations when a photo reaches a specified photo status, i.e. PENDING, APPROVED, DENIED, DISCARDED, READY_FOR_DOWNLOAD, DOWNLOADED, DONE, ENROUTE, ON_HOLD.

Example Use Case

Acme Co. wants to import photos into their in-house org chart application whenever any photo reaches the DOWNLOADED status. In their org chart application, they consume photo status messages from AWS SQS or SNS, as described below. They download the binary photo data from the URL in the links.bytes property and store the data in their org chart application.

Consuming photo status messages from an SQS Queue

The specifics of interacting with SQS are outside the scope of this documentation because AWS already maintains thorough documentation, and most major programming languages have existing libraries for interacting with AWS. However, the high-level process for consuming SQS Photo Status Messages is as follows:

  1. Receive a message or a list of messages

  2. Handle debouncing (if relevant). Ideally, message processing is idempotent because SQS provides at-least-once delivery, but messages may be received more than once in some situations. If you receive multiple messages with the same combination of id and status, you have likely received a duplicate message.

  3. Handle order message ordering (if relevant). Status Queues generally deliver status messages in order, but this is not strictly guaranteed, and AWS FIFO SQS queues are not currently supported.

  4. Process the message(s). See the example message body below.

  5. Delete the message(s) from SQS. Otherwise, the message(s) will continue to be received by your client after the visibility timeout expires.

Consuming photo status messages via an SNS Topic

The specifics of interacting with SNS are outside the scope of this documentation because AWS already maintains thorough documentation, and most major programming languages have existing libraries for interacting with AWS. However, the high-level process for consuming SNS Photo Status Messages is as follows:

  1. Subscribe an HTTP endpoint, AWS Lambda function, etc., to the topic.

  2. In your subscriber, handle SNS messages received from the topic. See the example message body below.

SQS vs SNS: Which to Use

We recommend SQS, but depending on the architecture of your client application, SNS may be a better fit. We like SQS because of the durability of the integration; if your application has an outage, messages that were sent while your app was down will still be in the queue and can still be processed when your app comes back up. SNS supports pushing real-time messages to your app, but setting up a recurring job to consume SQS messages via long polling delivers messages in near-real-time. For more information on this topic, consider the following posts:

Sample Photo Status Message

{ "domainClass": "us.cloudcard.api.Photo", "publicKey": "135404.23.331.YM9K3anh92S12oR2p0o07dC50T0pHfkp5149GeofGPgvl4tWKOGbvJutY1uMSrk1HVN9o7RS2qWB1Zg2", "manuallyEdited": false, "person": { "id": 605353, "username": "tony+1dj3n@acme.com", "email": "tony+1dj3n@acme.com", "identifier": "ABC000123456", "customFields": { "Full Name": "John Smith" }, "organization": { "id": 135404, "name": "Acme Co.", "identifier": "acme" }, "additionalPhotos": [], "additionalPhotoRequired": true }, "status": "DOWNLOADED", "originalPhoto": null, "dateCreated": "2023-11-27T05:40:45+0000", "id": 1419977, "links": { "bytes": "https://s3.amazonaws.com/test-photos.onlinephotosubmission.com/100404.23.331.YM9K3anh92S12oR2p0o07dC50T0pHfkp5149GeofGPgvl4tWKOGbvJutY1uMSrk1HVN9o7RS2qWB1Zg2.jpg" }, "version": 2, "lowestClassification": 0.99846, "backgroundReplaced": true, "aspectRatio": 1, "helperBotReviewed": true, "isAspectRatioCorrect": true }

See Also:

Â