-
Notifications
You must be signed in to change notification settings - Fork 255
Handle MessageExpiryInterval early enough for retained messages to honor it #442
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
base: main
Are you sure you want to change the base?
Conversation
Thank you @dariopb for the PR. The identification of the issue is correct. In reviewing this, I found we're not providing consistent behavior when MaximumMessageExpiryInterval is set to 0. So we may need to make larger modifications.
Which meaning do you prefer? |
@thedevop I think if we are to look at it logically, then 0 should be expire immediately. We can always set an very high expiry (maxint), but we cannot otherwise set expire immediately (unless we set it to 1 and then there's a short delay). If 1 expires after 1, then 0 should expire immediately I think. What do you think? |
Pull Request Test Coverage Report for Build 12403881253Details
💛 - Coveralls |
Ok, so when MaximumMessageExpiryInterval is 0, it means expire immediately. We can use MaxInt to make it effectively unlimited if needed. @dariopb, let me know if you can make the the corresponding changes in this PR or I can submit a separate PR. |
@mochi-co, looking at this further, we will create conflicts if we define define MaximumMessageExpiryInterval == 0 as expire immediately. We have the following:
According to MQTTv5 spec, when a message doesn't have expiry, it should not expire. When the message received does't have expiry set, then currently pk.Properties.MessageExpiryInterval is 0, to mean message doesn't expire. If we allow MessageExpiryInterval == 0 to mean expire immediately, it will create conflict. Currently pk.Expiry == 0 also means no expiration. So if we change that to mean expire immediately, then effectively we will also be setting pk.Properties.MessageExpiryInterval to 0 for outgoing messages. Now if we define MaximumMessageExpiryInterval == 0 as expire immediately, it can result in pk.Expiry set as 0, create a conflict. So to be consistent. we should define MaximumMessageExpiryInterval == 0 as no expiration limit. I have created a new PR that:
|
Setting the
pk.Expiry
member to the right value early enough so it is correctly saved when the message is retained inRetainMessage
.Without the change, even if we set the MessageExpiryInterval for retained message, the message won't expire at that interval since it was stored already with the default value (0) for
pk.Expiry
.