How can I configure to let HiveMQ allow dollar-topics?


I found from here( that
“$” can not be used when you publish a message.
And indeed I found this from the code:
public static final AtomicBoolean MQTT_ALLOW_DOLLAR_TOPICS = new AtomicBoolean(false);

And I want to ask if I can change it to true to let HiveMQ allow dollar-topics?

Thank you.

Hi @chengxiangwang,

yes you can change MQTT_ALLOW_DOLLAR_TOPICS to true (and build your custom hivemq ce zip) then you can publish to $ topics with your clients.

Not sure what you want to do, maybe you can also benefit from the PublishService as this service can publish to $ topics without changing the internal config.

Michael from the HiveMQ team

1 Like

Thank you for the reply!
But I don’t want to rebuild it, can you tell me more detail of how to use the “PublishService”?

Hi @chengxiangwang,

sorry for the delayed response (I had holiday). Simple example for sending a publish via the publish service:

Publish message = Builders.publish()


I don’t know when you should use it (i.e. in what interceptor, etc.), as I don’t know your use case for using the dollar topic. If you need help here you should describe your use case.

Here is the link to the full publish service documentation:

Kind regards,