Create a new topic in Google Pub/Sub

To create a new topic in Google Pub/Sub, go to, then click the Create Topic button to create a new topic!

The following window will be displayed:

Topic ID is the name of the topic you want to create. Here, we also have 4 other configurations for a topic that you can choose before creating this topic.

Add a default subscription: in short, a subscription helps subscribers to receive a message published on the topic. Only topics that have defined a subscription associated with it are available for subscribers to be able to subscribe to. You can go to and create a new Subscription. Configuring a default subscription will help us automatically create a new subscription for a new topic, the default value will be the topic name plus “-sub”. In this example, I will choose this configuration!

Use a schema: used to define the format of messages published to the topic. We can define a Schema at, then select this configuration to use the schema for the new topic. For simplicity, I will not use a schema for my new topic!

Set message retention duration: used to define how long a message published to this new topic is stored. This configuration as you can see will cost money, so if you don’t have a need, don’t use it. I will not use this configuration!

Use a customer-managed encryption key: this configuration is used to define a mechanism to encrypt messages in this new topic. You can read more here to understand more about the encryption mechanisms that Google Pub/Sub supports. For the sake of simplicity, I don’t use this configuration either!

I will name the topic as huongdanjava and click the Create topic button.

My result is as follows:

Add Comment