Quickstart: using the Google Cloud Console

This page shows you how to perform basic tasks in Pub/Sub using the Google Cloud 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 Cloud Console project.

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

  3. Install and initialize the Cloud SDK.

Create a topic

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

    Go to the Pub/Sub topics page

  2. Click Create a topic.

    Screenshot that shows the Create a topic dialog in the console

  3. In the Topic ID field, provide a unique topic name, for example, MyTopic.

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

  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

  1. In the Cloud Console, go to the Pub/Sub subscriptions page.

    Go to the Pub/Sub subscriptions page

  2. Click the subscription ID.

  3. In the Subscription details page, click View messages.

  4. Click Pull.

Clean up

To avoid incurring charges to your Google Cloud account for the resources used in this quickstart, follow these steps.

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

    Go to the 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 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?