How to create a new Pub/Sub Topic on Google Cloud

Riyaz Walikar
Feature image


Pub/Sub helps with messaging in between applications. A Cloud Pub/Sub is designed to provide reliable, many-to-many asynchronous messaging between applications. Publisher applications can send messages to a Topic and other applications can Subscribe to that Topic to receive the messages.

In Google Cloud, Pub/Sub allows applications and services to communicate asynchronously. It delivers low-latency/durable messaging in between application and services, it is commonly used by developers in implementing asynchronous workflows, distributing event notifications, and streaming data from various processes or devices.

Creating a Pub/Sub Topic

Following are the steps to create Pub/Sub Topic on Google Cloud:

  1. Login to Google Cloud console https://console.cloud.google.com/

  2. Once logged in, navigate to https://console.cloud.google.com/cloudpubsub/topic/list

  3. Click on the “Create Topic” button

    Create Pub/Sub Topic

  4. A pop up to Create a topic will appear. Add the Topic ID here

    Enter Pub/Sub Topic details

  5. Under the Topic ID you can see three options, “Add a default subscription”, “Use a schema”, and “Set message retention duration”. Select the option that is applicable to your use case. In the following sections, all three options have been covered

  6. Finally, click on the “Create Topic” button

Add a default Subscription

To add a default Subscription just select the option and by default it will provide the following features:

We can also create a customized Subscription after the Topic has been created. The steps are as follows:

  1. Navigate to https://console.cloud.google.com/cloudpubsub/subscription/list/ and click on the “Create Subscription” button

    Pub/Sub create subscription

  2. Once the subscription window opens then provide a Subscription Name and select the Topic ID for which you want to create the Subscription

    Pub/Sub create subscription details

  3. Dead-lettering settings allow you to store the messages to a dead letter topic when it cannot be delivered

    Enable Dead-lettering

  4. Leaving other options as default, select create.

Use a schema

A schema is a format that messages from a topic must follow. When creating a topic you can choose to create a new schema to assign to it, or assign it an existing schema. Select the Pub/Sub schema and then the message encoding language

Set message retention duration

When Set message retention duration is enabled, it retains the messages on the Topic for up to 31 days. This is a paid feature.

Set message retention duration


Pub/Subs allow for asynchronous messaging and is widely used with many applications. In this article we took a look at Google Cloud Pub/Sub and covered the steps for creating a new Topic. We also looked into various options that are available to us while creating a Topic. This article is a quick walkthrough for those getting started with Google Cloud Pub/Sub.

← Back to Academy