# Based on shared subscription

**URL:** <https://community.hivemq.com/t/based-on-shared-subscription/247>\
**Category:** Uncategorized\
**Created:** [July 4, 2020, 5:46am UTC](https://community.hivemq.com/t/based-on-shared-subscription/247 "2020-07-04T05:46:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fini](https://avatars.discourse-cdn.com/v4/letter/f/e47c2d/32.png) [@fini](https://community.hivemq.com/u/fini)\
**Post date:** [July 4, 2020, 5:46am UTC](https://community.hivemq.com/t/based-on-shared-subscription/247/1 "2020-07-04T05:46:19Z")

</div>

Currently, I have done a Shared subscription and the broker randomly selects one subscriber in each group and sends a message to that subscriber. I want it more like group communication, where one member of each group receives a message they pass this message to every other member of the group. So that each subscriber receives every message. How can I do it?

---

<div class="post-metadata">

**Author:** ![michael\_w](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.hivemq.com/michael_w/32/200_2.png) [@michael\_w](https://community.hivemq.com/u/michael_w)\
**Post date:** [July 5, 2020, 3:40pm UTC](https://community.hivemq.com/t/based-on-shared-subscription/247/2 "2020-07-05T15:40:27Z")

</div>

Hello @fini,

> I have done a Shared subscription and the broker randomly selects one subscriber in each group and sends a message to that subscriber.

That is how shared subscriptions work.

> I want it more like group communication, where one member of each group receives a message they pass this message to every other member of the group.

An shared subscription can’t do this, as they are not intended for that.

Possible solutions are…

- Client base solution: let each client that received a message for a shared subscription republish that message to an “internal topic” where only the other clients in the shared group are subscribed (with a normal subscription).
- Extension system: build a collection that holds information about all clients that have a shared subscription (use the SubscribeInboundInterceptor to do that), then in the PublishOutboundInterceptor you could then check if a message goes to one of the clients and republish it accordingly to the other clients in the shared group (using the PublishService).

Though both solutions only work if your shared group clients are only subscribed to the shared subscription topic filter and don’t have another overlapping subscription to that topic filter (i.e. can’t have $share/group1/topic1 and topic1 subscription).

Hope that helps,  
Michael from the HiveMQ team

---

<div class="post-metadata">

**Author:** ![sauroter](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.hivemq.com/sauroter/32/18_2.png) [@sauroter](https://community.hivemq.com/u/sauroter)\
**Post date:** [July 6, 2020, 7:31am UTC](https://community.hivemq.com/t/based-on-shared-subscription/247/3 "2020-07-06T07:31:07Z")

</div>

Hi @fini,

what prevents your clients from just subscribing all to the topic of interest?

This would be pretty much what pub/sub is made for:

[https://www.hivemq.com/blog/mqtt-essentials-part2-publish-subscribe/](https://www.hivemq.com/blog/mqtt-essentials-part2-publish-subscribe/)

Have a nice day  
Georg

---

<div class="post-metadata">

**Author:** ![fini](https://avatars.discourse-cdn.com/v4/letter/f/e47c2d/32.png) [@fini](https://community.hivemq.com/u/fini)\
**Post date:** [July 22, 2020, 5:10am UTC](https://community.hivemq.com/t/based-on-shared-subscription/247/4 "2020-07-22T05:10:41Z")

</div>

Thanks for your reply
