MQTTRetainedMessageManager improvement proposal #1763
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently the
MQTTRetainedMessageManagerinvokes an event to let listeners (i.e. a backing store) know when retained messages have changed. However, events raised in theUpdateMessagemethod do not convey what type of update has been performed, and the backing store would need to implement the same logic as present in theUpdateMessagemethod to replicate the same update action (i.e., check if the application message's payload is empty).What I'd like to propose is to change the
RetainedMessageChangedEventevent signature slightly to indicate whether a message has been added, removed or replaced. TheStoredRetainedMessagesmember can then be removed from event arguments (breaking change). Relying on the full list of stored retained messages in these events may prevent further improvements in this area.The included
Server_Invokes_Retained_Message_Eventsunit test demonstrates the use of the modified event.In the future, the
GetMessagesmethod and associated logic would probably need another look as it demands that all retained messages are made available in memory. Once that is resolved then the need for a separate implementation (i.e. viaIMqttRetainedMessagesManageras in #1663 or otherwise) may become less relevant.Any thoughts?