-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MQTT: replicated retained message store #8096
Comments
I'm not sure if it was done as part of #5895 #2554 #7263. @ansd @ChunyiLyu would know. |
@michaelklishin No, it was not done. Neither Native MQTT nor new feature requirements for MQTT 5.0 are related to replication of retained messages. As documented in https://www.rabbitmq.com/mqtt.html#retained support for retained messages has been very limited in RabbitMQ because it works wrongly when the RabbitMQ cluster consists of multiple nodes. More specifically, the current implementation stores retained messages only node local. This means depending on which node a client connects and subscribes, if there is a retained message for a given topic, it may receive no, outdated, or the latest retained message for that topic. Furthermore, wildcards in topic filters are not supported for retained messages. Given these limitations it makes sense to implement a new Some of the requirements could be:
Some limitations for the implementation are:
Before thinking about an implementation, the very first question is which of the above requirements do we need (all, or just a subset)? |
I'll elaborate more regarding my use-case. I terms of requirements:
Also, this is for MQTT 3.1.1 as I am not using MQTT 5. |
Thank you for explaining your use case @galah92. The solution will be much simpler if wildcards are not supported. We are a small team and while we invest into MQTT, our current focus has been improving scalability in #5895 and adding support for MQTT 5.0 in #7263 . |
Thank you for the explanation. As learning the RabbitMQ internals & Erlang sounds out-of-my-scope for now, I would have to go with a different solution, i.e. an external key-value store (Redis) and backend service to watch for device subscriptions to queues and publishing messages accordingly. For that I would need a way to store the currently subscribed topics. As these MQTT topics correspond to AMQP queues, I think this can be done by listening for In general, does that solution make sense? |
Yes, |
Dumping here one more good idea that came up by @kjnilsson.
This should provide very fast writes and reads as well as message replication while working with the current primitives available in RabbitMQ. @galah92 Yes, currently I see 2 possible workarounds for you:
|
You also need to decide what to do when redis is down or otherwise
unavailable. :)
|
I was able to create POC based on Redis and using |
The stream-based option seems better to me that a new embedded distributed key-value store. It will not be perfectly consistent when compared to what streams themselves offer due to the step that copied inbound data concurrently to an ETS table. Otherwise it can be perfectly sufficient. |
Hi, just saw 3.13.0-beta.1 was released. The release notes didn't mention anything related to message retention, but was is implemented by any chance? For MQTT 3 & 5. |
This issue is still open, so no, it has not been implemented. |
Hi all, we created a plugin to store the retained messges on a redis cluster. We are hosting our 3 node cluster on kubernetes. Maybe there is some interest on our implementation. Would be a pleasure to share it. |
@gery0815 you are welcome to leave a link to the plugin here but for any further discussions of it, use GitHub Discussions. |
@gery0815, would it be possible for you to share more information about the plugin you wrote for redis? |
@jdsdc @michaelklishin I started a discussion. There I also posted the link to my repo. Feel free to use ! #9431 |
Seems the redis plugin is not working with latest RabbitMQ version. Could I ask rabbitMQ maintainers if there is a WIP or an ETA to support cross nodes/replicas/pods retained messages store? I'm wondering if I'm the only one that consider this a big limitation, I use retained messages a lot to keep the state in sync but if I have multiple RabbitMQ nodes right now I cannot be sure my clients will receive all retained messages when they do a subscription as they are fethed just from the node they are connecting too. I think also this is not what users would expect it to work |
@ansd @kjnilsson I am very interested to know more about the solution based on the RabbitMQ streams that you presented here.
|
The solution based on streams, or rather certain internal stream API elements, is still very much a hypothesis to prove at this point. So are other options. There are no plans to introduce more plugins. |
We created how own implementation using Redis as a fork of @gery0815 one: https://github.com/innovation-system/rabbitmq-mqtt-retained-msg-redis This is something we really miss from RabbitMQ, hope one day there will be some work for supporting this 🙏🏼 |
Is your feature request related to a problem? Please describe.
I'm using RabbitMQ as MQTT Broker with the
rabbitmq_mqtt
plugin. I'm deploying RabbitMQ over Kubernetes with the Kubernetes Operator. According to the docs:I'd like to ask to support it over multiple replicas/nodes/pods.
The incentive is that if a client will be connected to a specific pod, disconnect and then reconnect to a different pod, I'd like this client to be able to subscribe to the same MQTT topic and get the same data.
Describe the solution you'd like
I'd like to be able to restore retained messages on MQTT topics from clients connected on multiple nodes/replicas/pods.
Describe alternatives you've considered
It is probably possible to emulate that with a backend that listens to client subscription on "retained" topics and corresponding DB/cache (Redis-like) to store message retention state.
But that doesn't sound right.
Additional context
No response
The text was updated successfully, but these errors were encountered: