time messages/passthrough queue
I am building a website which receives real-time updates about soccer matches. I am using RabbitMQ to send the updates to the clients (JS website and Android/iOS apps).
The clients should only receive real-time updates. In other words, a client should only receive updates when the user is logged in. No history is kept.
To achieve this behavior, I was thinking about the following architecture:
x-message-ttl
with value of 0 is set. See below. x-message-ttl
is set to 0. Is this a correct usage of AMQP/RabbitMQ to achieve real-time notifications?
Yes and no - some of your premises are wrong.
In other words, a client should only receive updates when the user is logged in.
When the user is not logged in, simply drop the connection to RMQ and that's it. Each user has a dedicated queue, which is bound to the exchange. This queue is created when the user account is created.
The queue should be created only after the connection to RMQ is established, in that way you are also covering the When a user is not logged in, the message will be discarded immediately
part. Messages are sent to the exchange by the backend, and forwarded to all queues
Just to be clear, it's the RabbitMQ that does "forwarding" from exchange to queues. 上一篇: AMINP上的AMQP / RabbitMQ消费者
下一篇: 时间消息/直通队列