You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Topics and subscriptions are the two fundamental resources in Google Cloud Pub/Sub. Topics are where publishers send messages, and subscriptions are how subscribers receive them. Understanding how to create, configure, and manage these resources is essential for building reliable messaging systems.
A topic is a named resource that acts as a message channel. Publishers send messages to a topic, and Pub/Sub distributes copies of each message to all subscriptions attached to that topic.
# Create a topic
gcloud pubsub topics create orders-topic
# Create a topic with a schema for message validation
gcloud pubsub topics create orders-topic \
--schema=orders-schema \
--message-encoding=json
# Add labels for organisation and billing
gcloud pubsub topics update orders-topic \
--update-labels=team=payments,env=production
# Delete a topic (does not delete subscriptions)
gcloud pubsub topics delete orders-topic
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.