The gcloud command-line tool is included in the Cloud SDK. This tool is used to perform operations in Cloud Pub/Sub. As we can see in the following program, first we are creating a topic with the name myTopic. Then we are creating a subscription mySubscription and assigning it to myTopic. Once this is done we are sending data or publishing data to the topic, myTopic with the message Hello World!!.
And the last thing that we are doing is to pull the subscription to receive the data. You can also use push subscription.
gcloud initgcloud pubsub topics create myTopicgcloud pubsub subscriptions create --topic myTopic mySubscriptiongcloud pubsub topics publish myTopic --message “Hello World !!!”gcloud pubsub subscriptions ...