Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQS - Get Message By Id

Tags:

amazon-sqs

Is it possible for me to get a message from the SQS queue based on the message ID with the Amazon PHP SDK? Do I have to just grab all of the messages on the queue and then filter it on my server?

My server receives a SNS instigated request with a queue message Id and I'm having to filter the message from an array of messages from SQS.

like image 209
A23 Avatar asked Jul 03 '14 03:07

A23


2 Answers

Just so that it may help someone else. I couldn't find a straight forward method to do this. Instead, implementing another set of queue workers to delegate the tasks solved the performance issue. These workers performed only two tasks

  1. Retrieve queue item
  2. Associative valid id
  3. Send it to the processing server (after performing load checks, availability etc)
like image 28
A23 Avatar answered Nov 18 '22 22:11

A23


The purpose of a queue is to use it as a buffer to store messages before a certain processing task. This should not be confused with a storage service or a database service. Amazon SQS allows a process to retrieve messages from a queue (buffer) and process them as needed. If needed Standard or FIFO queues can be used.

In answer to your question: SQS does not provide a mechanism to retrieve by Message ID. So as you suggested, you can have separate workers to retrieve all messages in parallel and look for the message with the ID you want. (This can be exhaustive)

Since your use case is similar to that of a storage service, I suggest writing to a storage service and retrieving from it based on a column named "Message ID".

like image 126
Keet Sugathadasa Avatar answered Nov 18 '22 23:11

Keet Sugathadasa