Andrea <selva...@gmail.com> writes:
> I'm implementing shared subscriptions on broker and despite the
> specification is clear when a shared subscription ceases to exist, I have
> troubles understanding what happens to the shared subscriptions when the
> broker restarts.
> Those subscription aren't part of the session state but are part of the
> broker state.
> Should be resilient to broker restarts?
Can you walk us through your analysis of the spec, in which sections it
talks about persisting state across broker restarts?
Without trying to read the spec, I would expect that a broker restart,
if persistence is implemented, should be like a network outage and the
clients reconnecting.
To address this, you have two options. You can either set cleansession to false, keeping your session information on the server until the final disconnect (note that the session information may linger), or you can handle your subscriptions in the OnConnect handler. The latter ensures that subscriptions are reestablished every time you are connected, even when autoreconnect is in action.
If maintaining consistent subscriptions is a priority for your application, utilizing the OnConnect() callback to handle subscriptions ensures that it is triggered every time the client is reconnected. Hope my answer helps!!