Mohamed Elloumi
Mohamed Elloumi

Reputation: 158

Delete some messages from the AWS SQS queue before polling

I have one Node.js application that pool messages from an AWS SQS queue and process these messages.

However some of these messages are not relevant to my service and they will be filtered out and not processed.

I am wondering if I can do this filtering stuffs from AWS before receiving these irrelevant messages ...

For example if the message does not have the following attribute data.name than this message will be deleted before reaching my application ...

Filtering these messages before sending them to to the queue is not possible (according to my client).

Upvotes: 0

Views: 1498

Answers (1)

Matus Dubrava
Matus Dubrava

Reputation: 14462

No that is not possible without polling the message itself. So you would need some other consumer polling the messages and returning them to queue (not calling DeleteMessage on the received delete handle) if they meet your requirements but that would be overkill in most of the cases, depending on the ratio of "good" and "bad" messages but still you would have to process "good" messages twice.

Better way would be to set up additional consumer and 2 queues. Producer sends messages to the first queue which is polled by the first consumer whose sole purpose is to filter messages and to send "good" messages to the second queue which would then be polled by your current consumer application. But again, this is much more costly.

If you can't filter messages before sending them to queue then filter them in your consuming application or you will have to pay some extra for this extra functionality.

Upvotes: 2

Related Questions