Quickstart: Using the Console

This page shows you how to perform basic tasks in Google 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. Select or create a Cloud Platform project.

    Go to the Projects page

  3. Enable billing for your project.

    Enable billing

  4. Enable the Cloud Pub/Sub API.

    Enable the API

  5. Install and initialize the Cloud SDK.

Create a topic

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

    Go to the Google 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 Google 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 Cloud Pub/Sub topics page, place the cursor at the far right of the topic you created.
  2. Click Publish to publish a message to the topic.
  3. Enter Hello World in the Message field.
  4. 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):

  1. Install the Cloud SDK beta command component:

    gcloud components install beta
    
  2. Enter the following:

    gcloud beta 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:

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

    Go to the Google 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 Google Cloud Pub/Sub, see What is Google Cloud Pub/Sub?

Send feedback about...

Cloud Pub/Sub Documentation