moquette
moquette copied to clipboard
Retained message with QoS 0
hi andsel, just started to play with the broker, very nice work!
I just have a question, when sending retained message with QoS == 0, it seems like the message is not retained at all. I tried the same thing with another broker and retained messages work on all QoS levels.
A quick look at the source code shows that you deal with retained with QoS == 0 with a special case:
https://github.com/andsel/moquette/blob/master/broker/src/main/java/org/eclipse/moquette/spi/impl/ProtocolProcessor.java#L311
Is this the intended behavior?
Thanks!
Hi @env3d it follow the specification [MQTT-3.3.1-7] "If the Server receives a QoS 0 message with the RETAIN flag set to 1 it MUST discard any message previously retained for that topic. It SHOULD store the new QoS 0 message as the new retained message for that topic, but MAY choose to discard it at any time - if this happens there will be no retained message for that topic.
As the specification says "MAY choose to discard it", would you accept a pull requests that makes this configurable through some point? ie, a cache with a max number of retained Qos-0 messages that are evicted by least usage?
Could be a great thing, but could you describe better the PR. For example you intend to use an external cache library?If yes, we need to speak about because I'm on the way to introduce Hazelcast as a medium to provide HA in Moquette.
Thanks Andrea
I was thinking of using Guava for the caching purposes. It seems very lightweight and is very easy to use.
Hi,
same "problem" here. First, thank you for writing this great piece of software (on a side note, I wrote a monitor that shows clients, subscriptions, publications, and how they are linked together; another time).
Did you make this configurable (retaining QoS = 0 messages)?
Cheers,
Chris