Why do you need a message queue for a chat with web sockets?

前端 未结 3 1519
醉梦人生
醉梦人生 2021-02-02 01:58

I have seen a lot of examples on the internet of chats using web sockets and RabbitMQ (https://github.com/videlalvaro/rabbitmq-chat), however I do not understand why it is need

3条回答
  •  粉色の甜心
    2021-02-02 02:10

    Simple answer ...

    For a simple chat app you don't need a queue (e.g. signalr would do exactly this without the queue).

    Typically though real world applications are not just "a simple chat app", the queue might represent the current state of the room for new users joining perhaps, so the server knows what list of messages to serve up when that happens.

    Also it's worth noting that message queues are often implemented when you want reliable messaging (e.g. Service bus) to ensure that all messages definitely get to where they should go even if the first attempt fails. So it's likely that the queue is included in many examples as a default primer in to later problem solving.

提交回复
热议问题