简体   繁体   中英

ActiveMQ Artemis / Telegraf / InfluxDB - is there a way to clone an MQTT message from a single topic to multiple topics?

I'm trying to use ActiveMQ Artemis to receive a single MQTT message, and then clone it to multiple topics.

For example, a single MQTT message with the topic "mydata/PC" is published to ActiveMQ Artemis.

Through some mechanism, ActiveMQ Artemis copies the message, and changes the topic of the first one to "mydata/PC/1" and the second one to "mydata/PC/2".

The listeners (which are Telegraf plug-ins) are listening on PC 1 and the other on PC 2. They would each get their own topic and publish it to their respective InfluxDB databases.

In case PC 2 is down or segmented the listener on that PC will not receive the message (which arrives on PC 1), and therefore the message will be not be cleared from ActiveMQ Artemis until the listener comes back up.

Does this approach sound feasible?

If not, another possibility is if there were some way to specify that the message can't be cleared until it is read twice or n amount of times. That would also work.

This is similar the the JMS concept of a message not being deleted until all subscribers to a topic have been successfully notified. Unfortunately, there are no pre-written telegraph consumers for JMS.

The MQTT protocol itself can already handle this use-case. You don't need to use ActiveMQ Artemis to receive a single MQTT message and then clone it to multiple topics.

Each of your Telegraf plug-ins can create a subscription with clean = false on "mydata/PC" and both of them will receive every message sent to that topic. If they get disconnected they can reconnect and pick up right where they left off (since clean = false will keep the subscription while the client is disconnected).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM