This page shows you how to perform basic tasks in Pub/Sub using the Google Cloud Console.
Before you begin
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
Set up a Cloud Console project.
Click to:
- Create or select a project.
- Enable the Pub/Sub API for that project.
You can view and manage these resources at any time in the Cloud Console.
- Install and initialize the Cloud SDK.
Create a topic
Go to the Pub/Sub topics page in the Cloud Console.
Click Create a topic.
In the Topic ID field, provide a unique topic name, for example,
MyTopic
.Click Save.
That's it—you've just created a 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 overflow menu for the topic you just created, click Publish Message.
- Enter
Hello World
in the Message field. - Click Publish.
Pull the message from the subscription
In the Cloud Console, go to the Pub/Sub subscriptions page.
Click the subscription ID.
In the Subscription details page, click View messages.
Click Pull.
Clean up
To avoid incurring charges to your Google Cloud account for the resources used in this quickstart, follow these steps.
Go to the Pub/Sub topics page in the Cloud 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 Pub/Sub in your language of choice at 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 Pub/Sub, see What is Pub/Sub?