This page shows you how to perform basic tasks in Cloud Pub/Sub using the Google Cloud Platform Console.
Before you begin
-
Sign in to your Google Account.
If you don't already have one, sign up for a new account.
-
Set up a GCP Console project.
Click to:
- Create or select a project.
- Enable the Cloud Pub/Sub API for that project.
You can view and manage these resources at any time in the GCP Console.
- Install and initialize the Cloud SDK.
Create a topic
-
Go to the Cloud Pub/Sub topics page in the GCP Console.
-
Click Create a topic.

-
Enter a unique Name for your topic, for example, MyTopic.
That's it—you've just created a Cloud Pub/Sub topic!
Add a subscription
To add a subscription to the topic you just created:
-
Display the menu for the topic you just created, and click New subscription.

-
Type a name for the subscription, such as MySub.

-
Leave the delivery type as Pull.
- Click Create.
Publish a message to the topic
To publish a message to the topic:
- In the Cloud Pub/Sub topics page, place the cursor at the far right of the topic you created.
- Click Publish to publish a message to the topic.
- Enter
Hello Worldin the Message field. - Click Publish.
Pull the message from the subscription
To receive the message you just published, your subscription needs to perform a
pull operation. One way to do this is through the gcloud command-line tool
(included in the
Cloud SDK you installed in
Before you begin):
-
Enter the following:
gcloud pubsub subscriptions pull MySub
The message you sent appears in the DATA field of the command output.
Clean up
To avoid incurring charges to your Google Cloud Platform account for the resources used in this quickstart:
-
Go to the Cloud Pub/Sub topics page in the GCP Console.
-
Check the checkbox next to the topic that you created.
- Click Delete to permanently delete the topic.
- Delete any remaining subscriptions by displaying each subscription and clicking its trash can icon.
What's next
Get started with Cloud Pub/Sub in your language of choice at Cloud Pub/Sub Client Libraries.
See the Publisher and Subscriber guides to learn more about the concepts discussed in this page.
For a detailed overview of Cloud Pub/Sub, see What is Cloud Pub/Sub?