MQTTRetainedMessageManager improvement proposal#1763
Conversation
|
I have looked a bit further into Here is my trial (I haven't tried with an actual database behind): https://github.com/logicaloud/MQTTnet/tree/improve-mqttretainedmessagemanager-with-intercept-events It now becomes questionable whether it is worthwhile introducing a breaking change with this proposal, since it wouldn't prepare some path forward. So, I'd be happy to close. I'll leave this up for a few days in case there is some feedback, or feel free to close now. |
|
Please see my comment here: #1764 (comment) |
|
I close this one now; any improvements can flow into what comes out of discussion #1764. |
|
Closing. |
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?