Quickstart: using the console

This page shows you how to perform basic tasks in Cloud Pub/Sub using the Google Cloud Platform Console.

Before you begin

  1. Sign in to your Google Account.

    If you don't already have one, sign up for a new account.

  2. Set up a GCP Console project.

    Set up a 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.

  3. Install and initialize the Cloud SDK.

Create a topic

  1. Go to the Cloud Pub/Sub topics page in the GCP Console.

    Go to the Cloud Pub/Sub topics page

  2. Click Create a topic.

    Screenshot that shows the Create a topic dialog in the console

  3. 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:

  1. Display the menu for the topic you just created, and click New subscription.

    Screenshot of the console dialog that shows the New subscription
          button in the row for the topic.

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

    Shows the new subscription dialog and typing your subscription
          name in the Subscription name field.

  3. Leave the delivery type as Pull.

  4. Click Create.

Publish a message to the topic

To publish a message to the topic:

  1. In the overflow menu for the topic you just created, click Publish Message.
  2. Enter Hello World in the Message field.
  3. 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. You can use the Cloud SDK you installed in Before you begin. Alternately, you can use the Cloud Shell to run the following gcloud command:

    gcloud pubsub subscriptions pull --auto-ack MySub

The message you sent appears in the DATA field of the command output.

How did it go?

Note that additional resources and links are available on the Cloud Pub/Sub support page.

Clean up

To avoid incurring charges to your GCP account for the resources used in this quickstart:

  1. Go to the Cloud Pub/Sub topics page in the GCP Console.

    Go to the Cloud Pub/Sub topics page

  2. Check the checkbox next to the topic that you created.

  3. Click Delete to permanently delete the topic.

  4. 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?

Was this page helpful? Let us know how we did:

Send feedback about...

Cloud Pub/Sub Documentation