Search code examples
amazon-web-servicesaws-lambdaamazon-sqsamazon-mws

How to trigger an event everytime a notification is pushed on my AWS SQS destination?


I am using AWS SQS for Amazon MWS Order APIs. Everytime someone orders from a seller account who has added me as his developer, Amazon will send the notification to my AWS SQS Application.I can pull the notifications from there. But for this, I will have to create a scheduler to pull the notifications. Can I use any other AWS as a listener just to trigger my own service everytime a notification is pushed on my destination by Amazon? Can I use Lambda functions for it? I am new to AWS so I know only I little about it.


Solution

  • Yes, you can use lambda. Specifically you can setup Event Source Mapping between your SQS queue and lambda function.

    In this scenario, the Lambda service will be pulling the SQS queue for you, and invoking your function whenever there are messages. You don't have to do anything, in a sense that you don't have to worry about implementing pulling procedure.

    Lambda service takes care of pulling. It will also remove the message from queue if your function completes successful. Thus you don't have to expliclitly delete messages from the queue.