Rewrite a topic

瀏覽次數:125 次
跳到第一則未讀訊息

Fabio Semperboni

未讀,
2019年10月17日 下午4:43:252019/10/17
收件者: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

未讀,
2019年10月17日 下午5:15:372019/10/17
收件者: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

未讀,
2019年10月17日 下午6:16:412019/10/17
收件者: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

未讀,
2019年10月17日 下午6:28:372019/10/17
收件者: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

未讀,
2019年10月18日 凌晨2:46:472019/10/18
收件者:MQTT
Hi Dustin,
could you share your bridging mechanism? What do you mean with "V5"?
Thanks
Fabio

Florian Raschbichler

未讀,
2019年10月18日 凌晨4:01:532019/10/18
收件者: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

未讀,
2019年10月18日 上午8:03:462019/10/18
收件者: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

未讀,
2019年10月18日 上午11:13:532019/10/18
收件者: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.
回覆所有人
回覆作者
轉寄
0 則新訊息