Amazon SQS, is it possible to receive messages from SQS based on sender ID

We have several Amazon users who send messages to the same SQS queue. So is it possible to receive a message from the queue based on the sender ID? means returning a specific list of messages based on the sender ID.

+5
source share
2 answers

I assume that after the completion of the filtering operation it will be necessary to process the elements of the queue [entity]. Although several queues can certainly help, a more reliable way is to do the preprocessing and then (for example, filtering by sender ID), in my opinion, in an elegant way.

With the release of AWS Lambda, you can offload the filtering or preprocessing, and then click / place it in the appropriate places.

If you have your users who are queuing items, try the following approach.

You can try with 2 lambda functions [Feeder and Worker].

Feeder will have a scheduled lambda function , whose task is to take elements from SQS (if any) and click it as SNS theme (and keep doing this forever)

The worker will be involved in listening to the SNS topic, which will do data filtering [depending on the sender ID]. Past items can be moved to a new queue, and the rest can be undone.

It would be best if your users clicked objects directly on the SNS topic, and the lambda filter function could do the filtering directly.

+2
source

No, you can’t filter the request for receiving a message on senderid, you will need to read all the messages and throw out (return) those that do not match, but this is not the best way to go - you will pay for all these read requests and throw many messages (i.e. return them to the queue).

While all the β€œwrong” consumers do this, a consumer who really wants / needs their assigned messages will be blocked from actually receiving their own messages - perhaps for a very long time.

I'm not sure about your intentions, but it seems that you will be better off using several queues, one on senderid, if this is how you want to consume messages - there is no extra cost for creating additional queues.

+7
source

Source: https://habr.com/ru/post/1240158/


All Articles