简体   繁体   中英

How to trigger Lambda function using SNS based on SQS Queue

I am using Lambda function to push message to SQS queue. Once the message is placed in SQS queue i need to trigger other Lambda function to process the message in Queue.

I think this we can implement using SNS. I am new in AWS service, Please suggest solution to trigger Lambda function based on SQS queue messages with the help of SNS.

You don't need the SNS layer in between. From your first Lambda do 2 things

  1. Place a message in SQS and
  2. Trigger the Lambda that will process the event

Out of curiosity, why do you need to put the message to SQS. If your processing is trivial then you can straightaway process the message in your first lambda function itself.

This way you save the cost of SQS as well as of other Lambda

I think that will depend on the urgency of processing messages. If you want to process all the messages in Realtime then send them to SNS and subscribe your Lambda to that Topic.

Another scenario can be where you are processing your messages in realtime and any failure frequently occurs due to some dependency, then in those case send it to SQS and process through a Lambda Polling later.

Lambdas triggering is pretty flexible in all these cases, you can directly subscribe your lambda to SNS topic to process, Also you can schedule your lambda to run it on cron basis(useful in case of polling and processing SQS 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM