Search code examples
apache-kafkarabbitmqamazon-sqs

Can we filter messages from queue by date?


I'm in need of a message queue where I can receive only the messages that are associated with a certain date.

For example let's say

[
{message:"hello", sendto:"abc@gmail.com", sendat:"2020-07-29"},
{message:"hi", sendto:"def@gmail.com", sendat:"2020-07-30"},
{message:"how are you", sendto:"xyz@gmail.com", sendat:"2020-07-29"}
]

is list of messages in my queue.

So I would like the receive message 1 & 3 when I poll for messages with date "2020-07-29".

I am using SQS and I don't find the option to filter messages by date.

Could I use a message queue to achieve the above results?


Solution

  • It is not possible to filter the messages from queue based on a condition.

    But Amazon SQS offers message attribute functionality which allows you to include structured metadata (such as timestamps, geospatial data, signatures, and identifiers) with messages and these message attributes can be used to

    If you want to filter messages, you could use the seperate queues or a lambda function which can trigger by SQS event and execute the condition.