1

There will be thousands of messages in the SQS.

Is it possible in the Step functions wait until OrderId:123 (json) is in the SQS and then execute the Lambda function when specific Order Id is received?

Edit: Step Functions to call the Lambda function at regular intervals until it manages to retrieve a message with a particular attribute. OrderId attribute will be in the body message. For example:

{
  "OrderId": 1235,
  "Items": [{"Id":1, "Name": "Item 1"}]
}
I'll-Be-Back
  • 10,530
  • 37
  • 110
  • 213
  • Your question is confusing. Are you saying that you have a Step Function, and one of those steps involves a Lambda function that wants to retrieve data from an Amazon SQS queue? And you would like Step Functions to call the Lambda function at regular intervals until it manages to retrieve a message with a particular attribute? Is `OrderId` and attribute or is it in the `body` of the message? Feel free to edit your question to provide more details. – John Rotenstein Aug 10 '18 at 02:18
  • @JohnRotenstein Yes you are correct. Updated my question. – I'll-Be-Back Aug 10 '18 at 18:23

1 Answers1

2

No, it is not possible to selectively retrieve a message from Amazon SQS.

Your application can request to receive 1-10 messages from SQS, but cannot request specific messages.

See: Finding certain messages in SQS

You could use send the messages to Amazon SNS instead and then Filter Messages with Amazon SNS using attributes, and also subscribe the SQS queue to the SNS topic to send a copy of the message to SQS, but this is starting to get too complicated.

You should probably re-architect the solution to have incoming orders trigger the next activity, rather than searching for a given order response.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470