A topic is a named resource to which messages are sent by publishers. It acts like a mailbox where messages are stored until subscribers receive them.
Click to reveal answer
beginner
What is a subscription in Google Cloud Pub/Sub?
A subscription is a named resource representing the stream of messages from a single, specific topic, to be delivered to the subscriber.
Click to reveal answer
intermediate
How do topics and subscriptions work together?
Publishers send messages to topics. Subscribers create subscriptions to those topics to receive messages. Each subscription gets its own copy of every message sent to the topic.
Click to reveal answer
intermediate
What happens if a subscriber does not acknowledge a message in Pub/Sub?
The message remains unacknowledged and will be redelivered after a deadline, ensuring reliable delivery until acknowledged.
Click to reveal answer
beginner
Can a topic have multiple subscriptions in Google Cloud Pub/Sub?
Yes, a topic can have multiple subscriptions. Each subscription independently receives all messages published to the topic.
Click to reveal answer
What is the role of a topic in Google Cloud Pub/Sub?
AIt deletes messages after delivery
BIt delivers messages to subscribers
CIt processes messages before delivery
DIt stores messages sent by publishers
✗ Incorrect
A topic stores messages sent by publishers until subscribers receive them.
What does a subscription represent in Pub/Sub?
AA stream of messages from a topic to a subscriber
BA message queue for a topic
CA publisher sending messages
DA storage bucket for messages
✗ Incorrect
A subscription represents the stream of messages from a topic to a subscriber.
If a subscriber does not acknowledge a message, what happens?
AThe message is redelivered after a deadline
BThe message is lost
CThe message is deleted immediately
DThe subscription is deleted
✗ Incorrect
Unacknowledged messages are redelivered after a deadline to ensure reliable delivery.
Can one topic have multiple subscriptions?
ANo, only one subscription per topic
BNo, subscriptions belong to different topics
CYes, each subscription receives all messages
DYes, but subscriptions share messages
✗ Incorrect
A topic can have multiple subscriptions, each receiving all messages independently.
Who sends messages to a topic in Pub/Sub?
ASubscribers
BPublishers
CSubscriptions
DCloud Storage
✗ Incorrect
Publishers send messages to topics.
Explain how topics and subscriptions work together in Google Cloud Pub/Sub.
Think of topics as mailboxes and subscriptions as mailboxes' readers.
You got /4 concepts.
Describe what happens when a message is not acknowledged by a subscriber.
Consider how Pub/Sub guarantees message delivery.
You got /4 concepts.
Practice
(1/5)
1. What is the main role of a topic in Google Cloud Pub/Sub?
easy
A. To authenticate users
B. To receive messages from subscribers
C. To store messages permanently
D. To send messages to subscribers
Solution
Step 1: Understand the role of a topic
A topic is where messages are sent or published by a publisher.
Step 2: Differentiate topic from subscription
Subscriptions receive messages from topics, not the other way around.
C. Listening for messages... followed by Received:
D. Error because callback is not called
Solution
Step 1: Understand code flow
The code subscribes to a topic and sets a callback to print received messages and acknowledge them.
Step 2: Identify output behavior
It prints 'Listening for messages...' immediately, then prints 'Received: ...' when a message arrives.
Final Answer:
Listening for messages... followed by Received: <message content> -> Option C
Quick Check:
Subscribe prints listening then message received [OK]
Hint: Callback prints message after initial listening print [OK]
Common Mistakes:
Assuming callback runs before print
Thinking no output until message arrives
Ignoring message acknowledgment
4. You created a subscription but messages are not being received. Which of the following is the most likely cause?
medium
A. The subscription is not attached to the correct topic
B. The topic does not exist
C. The subscription name is too long
D. The messages are too large
Solution
Step 1: Check subscription-topic link
If subscription is not linked to the right topic, it won't receive messages.
Step 2: Evaluate other options
Topic existence is important but usually creation fails if topic missing; name length or message size usually cause errors, not silent no messages.
Final Answer:
The subscription is not attached to the correct topic -> Option A
Quick Check:
Subscription-topic mismatch blocks messages [OK]
Hint: Check subscription's topic link first if no messages [OK]
Common Mistakes:
Ignoring subscription-topic association
Assuming message size silently blocks delivery
Thinking subscription name length causes no messages
5. You want to ensure that messages published to a topic are delivered to multiple independent services. Which setup should you use?
hard
A. Create multiple topics, one per service, and one subscription per topic
B. Create one topic and multiple subscriptions, one per service
C. Create one subscription and multiple topics linked to it
D. Create one topic and one subscription shared by all services
Solution
Step 1: Understand message fan-out
One topic can send messages to many subscriptions, allowing multiple services to receive independently.
Step 2: Evaluate options
Create one topic and multiple subscriptions, one per service uses one topic with multiple subscriptions, which is the recommended pattern for multiple independent consumers.
Final Answer:
Create one topic and multiple subscriptions, one per service -> Option B
Quick Check:
One topic, many subscriptions for multiple services [OK]
Hint: Use multiple subscriptions on one topic for multiple receivers [OK]
Common Mistakes:
Creating multiple topics unnecessarily
Using one subscription shared by all services
Linking subscriptions to multiple topics
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.