the best way to design the topic in mqtt

Skip to first unread message


Jan 30, 2017, 7:34:21 PM1/30/17
Hi, my name is Q, choi, student of Sogang Univ. in South Korea. 
I am studying a messaging protocol these days, and recently  studying mqtt protocol.
I have few questions about how to design mqtt topic for the tree below.

(black: the company, blue: department, yellow: employee)

First, what is the most effective way to design topic?
(If i just use the tree,) 
For topic A, I have to subscribe 3 times.(/dept/d1/d5,   /dept/D1 ,   /dept/D2)

Second, how can I avoid overlap for tree above?
If i publish /dept/D1 , A gets 2 same messages.
how can A gets only one message?

Thank you for your time. I look forward to reading any responses I receive.


Q, Choi

Ranjith Kumar Diraviyam

Feb 1, 2017, 11:41:21 PM2/1/17

I wrote an article recently in medium on creating a Non intelligent Edge devices. There are two ways of developing a pheriphery device.  
  1. Creating an intelligent edge device.
  2. Creating a non intelligent edge device. 
The way in which you set the hierarchy of subscription tells that you want want to build an intelligent. In this caes you need to process the different messages you receive at the pheripery and ignore the redundancy.  

If you following the model 2, refer to the point 1 in the article "Don't build intelligent into your device".  you should have individuaal subscriptions for each edge device and your broker or the central server should be coded to make sure the messages are sent only once to the edge device. 

Hope this helps. 

Best Regards,

ನಾಗೇಶ್ ಸುಬ್ರಹ್ಮಣ್ಯ (Nagesh S)

Feb 2, 2017, 2:02:00 AM2/2/17
To begin with, an exact replication of an existing hierarchy is not always the best approach in designing topic hierarchy (for reasons similar to what you are seeing now).

I would create topic hierarchy simply as, /emp/A. Then, with an intermediate application the publications will be processed to resolve multiple memberships and then re-publishes (multiple messages perhaps, with some meta information) to /emp/A.

BTW, if you published to /dept/D1, A would receive one message on /dept/D1. It would receive another message when there is a publication on /dept/D1/D5.

Hope this helps.

To learn more about MQTT please visit
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

Reply all
Reply to author
0 new messages