Send MQTT message to specific client?

is there any chance to let HiveMQ send out a given message to a specific client only?

I know this is not covered by the MQTT standard and there are better ways to implement such use cases (like the MQTT 5 Request/Response Pattern), but I would like to replace an existing MQTT server that does not properly conform to MQTT patterns with HiveMQ without modification of the clients.


Hi @koalo ,

Nice to see your interest in MQTT and HiveMQ, welcome to the community!

In MQTT, whatever client subscribed to a topic will receive messages published on that topic. In order for only one client to receive messages, you can authorize only that particular client to subscribe to the topic and reject authorization for all other clients. This way only one client will subscribe to the topic and hence only that client will receive messages published on the topic. In MQTT, this is called Topic Authorization.

In case if Topic Authorization does not suit your use case:

  • The HiveMQ Enterprise Edition comes with a HiveMQ Enterprise Extension SDK, which can be leveraged for what you are trying to achieve.

  • I suggest you reach out to our colleagues at and schedule a meeting to dive deeper into your specific requirements.

I hope this helps,
Kind regards,
Dasha from HiveMQ team

Hi Dasha,
thanks a lot! Using topic authorization for such a scenario is a great idea! Unfortunately all my clients subscribe to the same topic. So I will have a deeper look if it is realizable with an extension.


Hi Dasha,
writing an extension to do this job was surprisingly simple as shown below. Of course, some details need to be sorted out for our specific use case, but the main problem is solved. Thanks a lot!


    public void onOutboundPublish(
        final @NotNull PublishOutboundInput input, 
        final @NotNull PublishOutboundOutput output) {
        final String clientId = input.getClientInformation().getClientId();
        final String topic = input.getPublishPacket().getTopic();
        if (topic.startsWith("topsecret") && !clientId.startsWith("jamesbond")) {
1 Like

@koalo ,
very happy you found a way to implement the use case and thank you for sharing your solution – I hope it will be useful for our future community members :raised_hands: