moquette icon indicating copy to clipboard operation
moquette copied to clipboard

Retained message with QoS 0

Open env3d opened this issue 9 years ago • 5 comments

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!

env3d avatar Nov 11 '15 06:11 env3d

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.

andsel avatar Nov 22 '15 14:11 andsel

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?

redsolo avatar Feb 11 '16 06:02 redsolo

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

andsel avatar Feb 11 '16 21:02 andsel

I was thinking of using Guava for the caching purposes. It seems very lightweight and is very easy to use.

redsolo avatar Feb 24 '16 15:02 redsolo

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

ctreber avatar Aug 08 '17 16:08 ctreber