Search code examples
google-cloud-platformgoogle-cloud-functionsgoogle-cloud-pubsubgoogle-cloud-iot

Publish to different pubsub topic in Google cloud via mosquitto broker?


I have a pubsub topic name

projects/project_name/topics/Sandbox_PubSub

and I also have a subscription on that topic. and then I have a cloud function name Sandbox_function which triggers with a publish on that topic.

I have a python code where I am publishing the data to this topic via a mosquitto broker

'/devices/device_id/events/Sandbox_PubSub'

Its working perfectly fine and I am receiving data in the cloud function as well as in the subscription.

Now I created another topic name

projects/project_name/topics/Pairing

and then subscription and another cloud function called Pairing_Function Now when I publish my data on

'/devices/device_id/events/Pairing'

Instead of getting that data in Pairing_Function I am getting the data in Sandbox_Function as a subFolder Pairing and also in Sandbox_Subscription instead of Pairing subscription.

What i am doing wrong here? and how can i get data into different topics? thanks a lot!


Solution

  • I found it that we need to define the topics in the registry too.

    (see: IoT core -> Registry Edit -> Add more telemetry topics)

    We need to redirect the subFolder to specific topics