AMQP/RabbitMQ - 仅实时 messages/passthrough 队列

AMQP/RabbitMQ - Only real-time messages/passthrough queue

我正在建立一个接收足球比赛实时更新的网站。我正在使用 RabbitMQ 将更新发送到客户端(JS 网站和 Android/iOS 应用程序)。

客户端应该只接收实时更新。换句话说,客户端应该只在用户登录时接收更新。不保留历史记录。

为了实现这种行为,我正在考虑以下架构:

这是 AMQP/RabbitMQ 实现实时通知的正确用法吗?

是和不是 - 你的一些前提是错误的。

  • In other words, a client should only receive updates when the user is logged in. 当用户未登录时,只需断开与 RMQ 的连接即可。
  • Each user has a dedicated queue, which is bound to the exchange. This queue is created when the user account is created. 只有在与 RMQ 建立连接后才应创建队列,这样您也涵盖了 When a user is not logged in, the message will be discarded immediately 部分。
  • 无需将 TTL 设置为 0。
  • Messages are sent to the exchange by the backend, and forwarded to all queues 明确一点,是 RabbitMQ "forwarding" 从交换到队列。