英文:
SQS and multiple consumers
问题
我有一个创建消息的后端服务。我想要能够将创建的消息发送给客户端。为此,我已经在客户端与服务器之间创建了套接字连接。套接字端点服务器进行了水平扩展,我希望每个套接字端点服务器都能监听队列中传入的消息,然后将数据发送回已连接的客户端/会话。
为此,队列中传入的每条消息都必须被所有套接字端点服务器读取。我不确定是否可以使用 SQS 来实现这一点,因为根据文档(尽我所能理解),一旦服务器读取消息,它将被删除,因此对其他服务器(订阅者)而言将变得无法使用。
或者,我只能在所有订阅者都读取了消息之后才删除消息,但这意味着订阅者需要承受很大的开销。
因此,我的问题是,是否可以使用 SQS 来实现这一点。如果可以,那么如何实现?
如果不行,那么在这里可以使用什么消息服务。
谢谢!
英文:
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!
答案1
得分: 1
Amazon SQS不适合希望多个消费者读取一条消息的情况。相反,您应该考虑使用Amazon Simple Notification Service(Amazon SNS),它可以将每条消息发送到多个终端。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论