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

一笑奈何 提交于 2020-05-15 09:27:07

问题


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.


回答1:


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.




回答2:


There are many ways to do it, but if you want a modern, serverless approach, I'd set up a lambda function which does the SQS polling for you, as Marcin says above. You can then do anything you need to do with the message, whether it be read MWS for more order information or sync with your own systems. It's really quite flexible.



来源:https://stackoverflow.com/questions/60705578/how-to-trigger-an-event-everytime-a-notification-is-pushed-on-my-aws-sqs-destina

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!