Creating a Topic and Subscription with Pub/Sub in Google Cloud

45 minutes
  • 3 Learning Objectives

About this Hands-on Lab

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.

  1. From Google Cloud console’s main navigation, choose Pub/Sub.
  2. Click Create a Topic.
  3. Give your topic a name, click Create Topic.
  4. From the Topics dashboard, head over to the Pub/Sub menu and select Subscriptions.
  5. Select Create a Subscription.
  6. Name your subscription and then select your topic under Select a Cloud Pub/Sub Topic.
  7. For delivery type, you will leave this as Pull.
  8. Click Create.
Publishing a Message
  1. From the dashboard, head over to the Pub/Sub menu and select Topics.
  2. Once inside the Topics dashboard, click on the topic you have created.
  3. Click Publish a Message then Publish a single message.
  4. For publish type, leave it as single.
  5. In the message body, you will type in the message you will like to push.
  6. Click Publish.
Pulling the Message
  1. From the dashboard, head over to the Pub/Sub menu and select Subscriptions.
  2. Click on your subscription.
  3. Select View Messages.
  4. Under Messages, select Pull.

Additional Resources

Your team wants a setup in their environment where they would like to receive notifications on events and even possibly create some automation to respond to those event notifications. You've heard a lot about Pub/Sub, so you want to try to set up and test a topic and subscription to see how it works.

In this hands-on lab, you will:

  1. Create a Pub/Sub topic
  2. Create a subscription
  3. Publish a message
  4. Test pulling the message within your subscription

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?