# Publish and receive messages in Pub/Sub using the Google Cloud console

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

*** ** * ** ***

To follow step-by-step guidance for this task directly in the
Google Cloud console, click **Guide me**:

[Guide me](https://console.cloud.google.com/freetrial?redirectPath=/home/dashboard?tutorial%3Dpubsub--publish_receive_messages_console)

*** ** * ** ***

## Before you begin

## Create a topic

1. In the Google Cloud console, go to the **Pub/Sub**
   page.


   [Go to Pub/Sub](https://console.cloud.google.com/cloudpubsub/topicList)
2. In the **Topics** page, click **Create topic**.

3. In the window that opens, enter `MyTopic` in the **Topic ID** field.

   Leave the default values for the remaining options, and then click **Create**.

   You see the success message: `A new topic and a new subscription have been successfully created.`

   You have just created a topic called `MyTopic` and an associated default subscription `MyTopic-sub`.

## Add a second subscription

To add a second subscription to the topic you just created, complete these steps:

1. In the Google Cloud console, go to the **Pub/Sub subscriptions** page.

   [Go to Subscriptions](https://console.cloud.google.com/cloudpubsub/subscription/list)
2. In the **Subscriptions** page, click **Create subscription**.

3. Enter `MySub` in the
   **Subscription ID** field.

4. For **Select a Cloud Pub/Sub topic** , select the `MyTopic` topic from the drop-down menu.

5. Leave the default values for the remaining options.

6. Click **Create**.

   You see the success message: `Subscription successfully added.`

   The `MySub` subscription is now attached to the topic
   `MyTopic`. Pub/Sub delivers all messages sent to
   `MyTopic` to the `MySub` and `MyTopic-sub` subscriptions.

## Publish a message to the topic

1. In the Google Cloud console, go to the **Pub/Sub topics**
   page.

   [Go to Topics](https://console.cloud.google.com/cloudpubsub/topicList)
2. Click the `MyTopic` topic.

3. Click the
   **Topics**
   page and click `MyTopic`.

4. In the `MyTopic` page, click the **Messages** tab.

5. Click
   **Publish message**.

6. In the **Message body** window, enter `Hello World`.

7. Click **Publish**. A message displays at the bottom of the page that says "Message published" if the publish was successful.

## Pull the messages from the subscription

1. In the Google Cloud console, go to the **Pub/Sub subscriptions** page.

   [Go to Subscriptions](https://console.cloud.google.com/cloudpubsub/subscription/list)
2. In the **Messages** tab, click **Pull**.

You should see the message that you just published. The message has
the data, `Hello World`, and the time when the message was
published.

When using the Google Cloud console, an individual pull for a low
message volume can often return zero messages. If you do not see messages, click
**Pull** multiple times to issue multiple pull requests. This is not an issue
with the [Pub/Sub Client Libraries](https://docs.cloud.google.com/pubsub/docs/publish-receive-messages-client-library.md.txt).

## Clean up


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

If you no longer need the topic and subscription you created, you
can delete them.

To delete the topic and subscription, complete these steps:

1. Go to the
   **Topics**
   page.

2. Check the checkbox next to `MyTopic` and click
   **Delete**.

3. Complete the steps in the confirmation window to permanently delete the
   topic.

Or you can [delete the project](https://console.cloud.google.com/cloud-resource-manager) that you created.

## What's next

- Learn more about the Pub/Sub [concepts](https://docs.cloud.google.com/pubsub/docs/overview.md.txt)
  discussed in this page.

- Read the [basics of the Pub/Sub service](https://docs.cloud.google.com/pubsub/docs/pubsub-basics.md.txt).

- Work through an [end-to-end example](https://docs.cloud.google.com/pubsub/docs/building-pubsub-messaging-system.md.txt)
  of a Pub/Sub system.

- Try another Pub/Sub quickstart that
  uses [client libraries](https://docs.cloud.google.com/pubsub/docs/publish-receive-messages-client-library.md.txt)
  or the [Google Cloud CLI](https://docs.cloud.google.com/pubsub/docs/publish-receive-messages-gcloud.md.txt).

- Learn how to create [topics](https://docs.cloud.google.com/pubsub/docs/create-topic.md.txt)
  and publish [messages](https://docs.cloud.google.com/pubsub/docs/publisher.md.txt).

- [Choose](https://docs.cloud.google.com/pubsub/docs/subscriber.md.txt) or [create](https://docs.cloud.google.com/pubsub/docs/create-subscription.md.txt) a subscription.

- Learn more about [Pub/Sub APIs](https://docs.cloud.google.com/pubsub/docs/reference/service_apis_overview.md.txt).