Reputation: 1431
guys need small help, I have a use case, where I want to set up a communication service. using SQS, SQs is going to receive a different type of events to be communicated. Now we have a single lambda function which does a single communication. let's say one email Lambda, Slack lambda, etc.
how I can invoke different lambda based on queue attributes. I was planning to use SQS as an event source and something kind of this architecture link to sample architeture
here in the above, we can handle rate limiting and concurrency at the lambda service level simplified works if event type is A invoke Lambda A if the event type is B invoke a lambda B and both events are in same SQS
all suggestions are welcome
Upvotes: 1
Views: 1308
Reputation: 3450
Your problem is a SQS message can only be read by one service at a time. When it is being read, it is invisible to anyone else. You can only have one Lambda consumer and there isn't any partitioning or routing in SQS besides setting up another SQS topic. Multiple consumers are implemented Kensis or AWS MSK (Kafka)
What you are trying to accomplish is called a fan out. This is a common cloud architecture. What you probably want to do is publish initially to SNS. Then with SNS you can filter and route to multiple SQS topics for each of the message types and each SQS topic would then be consumed by it's own Lambda.
Check out a tutorial here: https://docs.aws.amazon.com/sns/latest/dg/sns-common-scenarios.html
Upvotes: 2