Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Labs

Utilizing Google Cloud Pub/Sub

Cloud Pub/Sub is Google Cloud's central fully managed messaging service. Being central, it is consequently incorporated in a lot of different workflows. Pub/Sub can be used to stream data to BigQuery, Cloud Functions, Stackdriver, Cloud IoT Core, and numerous other services. This hands-on lab will provide you with practical experience working with the necessary components of Cloud Pub/Sub: topics, subscriptions, and messages.

Labs

Path Info

Level
Clock icon Beginner
Duration
Clock icon 30m
Published
Clock icon Mar 14, 2019

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Enable APIs

    1. From the main console navigation, go to APIs and Services > Library.
    2. Search for Pub/Sub.
    3. Select the Cloud Pub/Sub card.
    4. Click Enable, if displayed.
  2. Challenge

    Create a Topic

    1. From the main navigation, go to Pub/Sub > Topics.
    2. Click Create a topic.
    3. Enter a name for the topic (e.g., "acg-topic-1").
    4. Deselect Create a default subscription.
    5. Click Create.
  3. Challenge

    Create a Subscription

    1. Drill down into the topic just created and choose Subscriptions.
    2. Click the icon in the Topic details navigation bar to create a subscription.
    3. Enter a name for the subscription (e.g., "acg-sub-1").
    4. Set Delivery Type to Pull.
    5. Leave the rest of the settings at their defaults.
    6. Click Create.
  4. Challenge

    Publish a Message

    1. From the Topic details page, click Publish Message.
    2. Enter a message in the Message field.
    3. Click Publish.
  5. Challenge

    Retrieve Message

    1. Activate the Cloud Shell by clicking its icon in the top row.

    2. If the Cloud Shell does not display the current project ID in yellow, open the Project panel by clicking the project name in the upper-left.

    3. Copy the current project ID.

    4. In the Cloud Shell, enter the following command:

      gcloud config set project <PROJECT_ID>
      
    5. To retrieve a message, enter the following command:

      gcloud pubsub subscriptions pull <SUBSCRIPTION_NAME> --auto-ack
      
    6. Confirm the message displayed is the same as published.

    7. Repeat the command again.

    8. Confirm zero messages are found.

  6. Challenge

    Publish Multiple Messages

    1. From the Topic details page, click Publish Message.
    2. Enter a message in the Message field.
    3. Click Publish.
    4. Repeat steps 1-3 twice more.
  7. Challenge

    Retrieve Multiple Messages

    1. In the Cloud Shell, enter the following command:

      gcloud pubsub subscriptions pull <SUBSCRIPTION_NAME> --auto-ack --limit=3
      
    2. Confirm all messages displayed are the same as were published.

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans