Pub/Sub is a fully-managed real-time messaging service that allows you to send and receive messages between independent applications. You can use Pub/Sub as messaging-oriented middleware or event ingestion and delivery for streaming analytics pipelines. In this hands-on Lab, we will set up a topic and subscription and then publish a message.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Creating a Topic and Subscription
Make sure the lab’s project is selected.
- From Google Cloud console’s main navigation, choose Pub/Sub.
- Click Create a Topic.
- Give your topic a name, click Create Topic.
- From the Topics dashboard, head over to the Pub/Sub menu and select Subscriptions.
- Select Create a Subscription.
- Name your subscription and then select your topic under Select a Cloud Pub/Sub Topic.
- For delivery type, you will leave this as Pull.
- Click Create.
- Publishing a Message
- From the dashboard, head over to the Pub/Sub menu and select Topics.
- Once inside the Topics dashboard, click on the topic you have created.
- Click Publish a Message then Publish a single message.
- For publish type, leave it as single.
- In the message body, you will type in the message you will like to push.
- Click Publish.
- Pulling the Message
- From the dashboard, head over to the Pub/Sub menu and select Subscriptions.
- Click on your subscription.
- Select View Messages.
- Under Messages, select Pull.