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

**URL:** <https://community.hivemq.com/t/how-can-i-configure-to-let-hivemq-allow-dollar-topics/311>\
**Category:** HiveMQ Community Edition\
**Created:** [August 21, 2020, 6:28am UTC](https://community.hivemq.com/t/how-can-i-configure-to-let-hivemq-allow-dollar-topics/311 "2020-08-21T06:28:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chengxiangwang](https://avatars.discourse-cdn.com/v4/letter/c/a9a28c/32.png) [@chengxiangwang](https://community.hivemq.com/u/chengxiangwang)\
**Post date:** [August 21, 2020, 6:28am UTC](https://community.hivemq.com/t/how-can-i-configure-to-let-hivemq-allow-dollar-topics/311/1 "2020-08-21T06:28:53Z")

</div>

Hi,

I found from here([https://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices/](https://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices/)) 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.

---

<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:** [August 21, 2020, 1:12pm UTC](https://community.hivemq.com/t/how-can-i-configure-to-let-hivemq-allow-dollar-topics/311/2 "2020-08-21T13:12:26Z")

</div>

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.

Greetings,  
Michael from the HiveMQ team

---

<div class="post-metadata">

**Author:** ![chengxiangwang](https://avatars.discourse-cdn.com/v4/letter/c/a9a28c/32.png) [@chengxiangwang](https://community.hivemq.com/u/chengxiangwang)\
**Post date:** [August 25, 2020, 2:31am UTC](https://community.hivemq.com/t/how-can-i-configure-to-let-hivemq-allow-dollar-topics/311/3 "2020-08-25T02:31:51Z")

</div>

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”?

---

<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:** [August 30, 2020, 3:53pm UTC](https://community.hivemq.com/t/how-can-i-configure-to-let-hivemq-allow-dollar-topics/311/4 "2020-08-30T15:53:13Z")

</div>

Hi @chengxiangwang,

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

```auto
Publish message = Builders.publish()
    .topic("$topic")
    .qos(Qos.AT_LEAST_ONCE)
    .payload(payload)
    .build();

Services.publishService().publish(message);

```

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: [https://www.hivemq.com/docs/hivemq/latest/extensions/services.html#publish-service](https://www.hivemq.com/docs/hivemq/latest/extensions/services.html#publish-service)

Kind regards,  
Michael
