Reputation: 1929
I'm in a situation where I need to process some notifications from a SNS topic. I'm thinking about processing this message in a Lambda function. I have to implementation in mind
Order of the message is import for the consumer application. Keeping this in mind which one seems to be a better implementation. Any pointers/explanation would be helpful.
Upvotes: 1
Views: 556
Reputation: 966
You can subscribe your SQS FIFO queues to an SNS FIFO topic. Then, you can have your queues trigger the Lambda functions, in order. Here’s an example: https://docs.aws.amazon.com/sns/latest/dg/fifo-example-use-case.html
Upvotes: 1
Reputation: 17435
It sounds more like multiple somewhat independent message streams. So if a created
event for EC2-1 came in before one for EC2-2 there really isn't an issue. In that case I would stick with the SNS -> Lambda method as the SQS method will require polling of the queue. The Lambda won't cost anything if it's not being used but you will (eventually) get charged for SQS polling.
There are many examples of how to handle the messages coming in. In Java, for example, you can use POJO handlers (a plain old java object for which Lambda has done the deserialization for you or you could used predefined objects that, in this case, are SNS specific.
Upvotes: 2