简体   繁体   中英

Publish data from MQTT topics to Google cloud pubsub topics

I am using paho.mqtt.client to read data from mqtt topic. Is there any way to publish data from multiple Mqtt topics to multiple Google Pubsub topics, ie mqtt_topic in Mqtt -> gcp_topic in Google cloud pubsub?

If you are using python then in order to send multiple messages to multiple topics using paho.mqtt you can use publish.multiple in python eg

msgs = [{'topic':"paho/test/multiple", 'payload':"multiple 1"},
        ("paho/test/multiple", "multiple 2", 0, False)]
publish.multiple(msgs, hostname="mqtt.eclipse.org") 

for further information take a look at the official documentation:

https://pypi.org/project/paho-mqtt/#multiple

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