- Cloud Pub/Sub is a fully-managed real-time messaging service for event driven systems that allows you to send and receive messages between independent applications.
- Capable of global message routing to simplify multi-region systems.
- Synchronous, cross-zone message replication and per-message receipt tracking ensure at-least-once delivery at any scale. Pub/Sub delivers each message at least once, so the Pub/Sub service might redeliver messages.
- You can declare independent quota and billing for publishers and subscribers.
- Cloud Pub/Sub doesn’t have shards or partitions. You just need to set your quota, publish, and consume.
- It is a named resource to which publishers send messages.
- Is a named resource representing the stream of messages from a specific topic, to be sent to the subscribing application.
- The combination of data and attributes that a publisher sends to a topic and is eventually sent to subscribers.
- Message attribute
- A key-value pair that a publisher can define for a message.
- A publisher application creates and sends messages to a topic.
- Subscriber applications then create a subscription to a topic to receive messages from the topic.
- Communication can be
- Pub/Sub pricing is calculated based upon monthly data volumes:
- Message ingestion and delivery
- Snapshots and retained acknowledged messages
- The first 10 GB of data per month is offered free of charge.
Validate Your Knowledge
You have an application packaged on a container that you plan to deploy on Cloud Run. The application performs some data analysis on messages from a Cloud Pub/Sub topic called
order-queue. You want to follow Google-recommended practices.
What should you do?
a. Build a Cloud Function that is triggered every time there is a message from a Cloud Pub/Sub topic.
b. Invoke your application on Cloud Run from the Cloud Function on every message.
a. Create a service account and use it for your Cloud Run application.
b. On IAM Roles, grant the Pub/Sub Subscriber role to the new service account.
c. Create a Pub/Sub subscription on the
order-queuetopic using the new service account.
d. Configure the Cloud Run application to pull messages from the subscription.
a. Create a service account.
b. Associate the Cloud Run Invoker role to the service account of your Cloud Run application.
c. Create a Cloud Pub/Sub subscription using the new service account and set the push endpoint using the service URL of your Cloud Run application.
a. Use Cloud Run for Anthos to deploy your application and expose your application to the public by setting the connectivity to
b. Create a Pub/Sub subscription on the
c. Deploy a new container that takes messages from Cloud Pub/Sub and sends it to your application.