I am trying to implement a service within a serverless architecture that will take "Orders" that are basically JSON objects, and every X number of orders, trigger a Lambda function to process those orders. I have read a fair bit about Amazon SQS as an option for something like this, but want to get confirmation that this is the right approach.
Can I use SQS to subscribe to an SNS feed that publishes orders, and then have a Lambda poll that queue to batch process orders that come in?
Thanks in advance.
I did some experimentation and found that:
SendMessageBatch()
Records
parameterTherefore, if your ordering system can send the messages to SQS as a batch, then the Lambda function will process them as a batch (up to the Batch Size). However, this would require you to 'buffer' the messages in the ordering system before sending them to Lambda , which has the potential for information loss if something goes wrong.
It is typically better to process the orders immediately unless there is a specific reason why you wish to use a batch.
Inserting Amazon SNS can be useful if you wish to "fan-out" the orders to multiple systems, but isn't necessary if you have only one destination for the messages.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.