Search code examples
amazon-web-servicesamazon-sqsmessage-queuepublish-subscribemessaging

SQS and multiple consumers


I have a backend service that is creating message. I want to be able to send the messages created to the clients. For this, I've created socket connections from client to the server. The socket endpoint servers are horizontally scaled, and what I want is for each of those socket endpoints server to listen to the messages coming in queue and then send data back to the clients/sessions connected.

For this, every message that comes in the queue has to be read by all the socket endpoint servers. I am not sure if I can use SQS for this, given (as much as i can figure from doc), once a server reads the message, it will delete it and hence that will become unusable for the other servers (subscribers)

Alternatively, I can only delete the message if it has been read by all the subscribers, but that means a lot of overhead on the subscribers part.

So my question is, is it possible to do this with SQS. If yes, then how? If not, then what messaging service can be used here.

Thanks!


Solution

  • Are are correct -- Amazon SQS is not appropriate if you want one message read by multiple consumers.

    Instead, you should consider using Amazon Simple Notification Service (Amazon SNS), which sends each message to multiple endpoints.