Rewrite a topic

131 views
Skip to first unread message

Fabio Semperboni

unread,
Oct 17, 2019, 4:43:25 PM10/17/19
to MQTT
Hi to all,
my goal is to rewrite a topic for instance from /sensor/IOT into /device/HW.
Is there any solutions to accomplish that?

thanks
Fabio

Dustin Sallings

unread,
Oct 17, 2019, 5:15:37 PM10/17/19
to mq...@googlegroups.com
Is this something you want your broker to do?  A broker could theoretically alias the path, but I don't know if that's implemented in any of them.

You could do it with an external bridge mirroring the pubsub to both locations.

Fabio Semperboni

unread,
Oct 17, 2019, 6:16:41 PM10/17/19
to MQTT
I use a broker in bridge mode, but I can only insert at the beginning or at the end of the topic a string.
My goal is to rewrite the topic.

Any suggestions?

thanks
fabio

Dustin Sallings

unread,
Oct 17, 2019, 6:28:37 PM10/17/19
to mq...@googlegroups.com

On Thu, Oct 17, 2019, 15:16 Fabio Semperboni <semp...@gmail.com> wrote:
I use a broker in bridge mode, but I can only insert at the beginning or at the end of the topic a string.
My goal is to rewrite the topic.

Any suggestions?

Depends on your broker. mosquitto can do prefix rewriting while bridging, but running a broker just to get it to bridge just to rewrite some topics seems a little overkill.

If that's a path you'd take, I'd just write a small external program to go it.  V5 makes it pretty easy to do that sort of thing.  My entire bridging mechanism is an external program that would be easy to adapt to such a task.

Fabio Semperboni

unread,
Oct 18, 2019, 2:46:47 AM10/18/19
to MQTT
Hi Dustin,
could you share your bridging mechanism? What do you mean with "V5"?
Thanks
Fabio

Florian Raschbichler

unread,
Oct 18, 2019, 4:01:53 AM10/18/19
to mq...@googlegroups.com
Hello Fabio,

You can use an extensible broker like HiveMQ for this.
With the HiveMQ Extension SDK you can write extensions that add extra functionality to the broker, like the re-writing of topics.
As a starting point, you need the PublishOutboundInterceptor for this. You can access the PUBLISH itself via the PublishOutboundOutbut and re-set the topic there.
As this is the MQTT mailing list and not supposed to be used for implementation specific questions, I invite you to use the HiveMQ Community Forum in case you have additional questions.

Hope this helps.

Cheers,
Florian@HiveMQ


--
To learn more about MQTT please visit http://mqtt.org
---
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 mqtt+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mqtt/b1d80d25-fabb-40b2-bc53-17a73692328b%40googlegroups.com.

Fabio Semperboni

unread,
Oct 18, 2019, 8:03:46 AM10/18/19
to MQTT
Thanks for the suggestion. If I do not find any 'native' solution, I'll try to write the extra functionality on HiveMQ.

thanks
fabio


Il giorno venerdì 18 ottobre 2019 10:01:53 UTC+2, Florian Raschbichler ha scritto:
Hello Fabio,

You can use an extensible broker like HiveMQ for this.
With the HiveMQ Extension SDK you can write extensions that add extra functionality to the broker, like the re-writing of topics.
As a starting point, you need the PublishOutboundInterceptor for this. You can access the PUBLISH itself via the PublishOutboundOutbut and re-set the topic there.
As this is the MQTT mailing list and not supposed to be used for implementation specific questions, I invite you to use the HiveMQ Community Forum in case you have additional questions.

Hope this helps.

Cheers,
Florian@HiveMQ
On 17. Oct 2019, at 22:43, Fabio Semperboni <semp...@gmail.com> wrote:

Hi to all,
my goal is to rewrite a topic for instance from /sensor/IOT into /device/HW.
Is there any solutions to accomplish that?

thanks
Fabio

--
To learn more about MQTT please visit http://mqtt.org
---
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 mq...@googlegroups.com.

Dustin Sallings

unread,
Oct 18, 2019, 11:13:53 AM10/18/19
to mq...@googlegroups.com

On Thu, Oct 17, 2019, 23:46 Fabio Semperboni <semp...@gmail.com> wrote:
Hi Dustin,
could you share your bridging mechanism? What do you mean with "V5"?
Thanks
Fabio

MQTT version 5 added a lot of features.  Some of them made it really easy for me to throw together a bridge to solve my own problems.

E.g., if you ignore the config parser, my bridge, which supports n-way replication of topics from and to arbitrary mqtt servers is just this code: https://github.com/dustin/mqtt-bridge/blob/master/app/Main.hs

I'm pretty sure I'm the only user and I've not bothered writing much documentation for it.  I rely on it to move traffic between my MQTT servers, though.
Reply all
Reply to author
Forward
0 new messages