Cloud Pub/Sub via Google Cloud Console

Navigate to Cloud Pub/Sub from the main menu, as shown in the following screenshot. Choose the Topics option under Pub/Sub:

Create a topic as shown in the following screenshot. A topic is like a category for messages that are sent/received between the applications:

Click on the menu button in the topic created and choose the New subscription option to create a new subscription to pull messages: 

Enter a name for the subscription and choose Pull as the delivery type, and then click on the Create button. This creates a subscription for messages of the type learningBigQuery:

Navigate to the Topics page and click on the menu button for the topic to send a sample message, as shown in this screenshot:

Enter the text for the message and the data to be sent with the message, as shown in the following screenshot. Click on Publish. This message will be sent to Cloud Pub/Sub:

To pull the message, open the Command Prompt to run commands that set up Google Cloud Pub/Sub. Run the command to pull the message and display it. Run the following command to update your local machine's Google Cloud SDK:

gcloud components update

Now run the following command to install Google Cloud Pub/Sub components in the Google Cloud SDK:

gcloud components install beta

Run the next command to pull the message through the subscription defined earlier. Replace learningBigQuerySub with the name of your subscription for the topic. The message will be deleted once an acknowledgment is received, hence, if you rerun this command, it will not show the message again. To get a peek at the message and not remove it, run without the --auto-ack flag:

gcloud beta pubsub subscriptions pull --auto-ack learningBigQuerySub

The output of the command will display the message text, message ID, data that was sent in the message, and acknowledgement ID:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.99.152