Question around message delivery in shared subscriptions

We are implementing a failover scenario, where we have N instances of a system, each having a consumer to a topic.

The topic is using a shared subscription ($share/testgroup/test/#), and there are multiple producers putting data into it, using topicnames like “testgroup/test/”.
The Qos is set to 2, for guaranteed delivery.

Each consumer registers with a unique id and the topic data is shared evenly across the clients.

If a consumer dies, the broker buffers the messages for that client, and the instance the client resumes operation, it picks up where it left off.

This is great but if the consumer is offline for a long period, these messages will soon back up, and from our viewpoint it would be better if the messages could then be redistributed from the brokers storage, to the next available consumer.

The instant the broken consumer comes back, the message distrubution should adjust back to it’s
original state.

Is this possible in MQTT please?

Is there a prescribed MQTT solution to this problem ?

Thanks in advance

Hi @DDixon2023 ,

Great to see your interest in MQTT and HiveMQ. Take a look at Declared Shared Subscriptions. Unlike a standard shared subscription, messages to a declared shared subscription are enqueued even if there are no connected shared subscribers for the topic.

I hope this helps
Kind regards
Dasha from HiveMQ team