Playing with Cloud Pub Sub V2 | Scribe

    Playing with Cloud Pub Sub V2

    • Hafeez Baig |
    • 52 steps |
    • 4 minutes
    1
    Sign in into the **Google Cloud Platform**
    2
    Type "**Pub/Sub**" in the search bar and click on the **Pub/Sub** option
    information ordinal icon
    **What is Pub/Sub?**\ \ **Pub/Sub** (Publisher/Subscriber) is a messaging service in Google Cloud that enables asynchronous communication between applications. It allows publishers to send messages to a topic, while subscribers receive messages from that topic. This decouples the systems, so publishers and subscribers can operate independently, making it easier to build scalable and flexible applications. Pub/Sub is commonly used for event-driven architectures, real-time analytics, and stream processing.
    3
    **Topics** wizard will open, click on the **Topics** from the left bar
    information ordinal icon
    **What are Topics?**\ \ **Topics** in Google Cloud Pub/Sub are named resources to which publishers send messages. A topic acts as a communication channel that allows multiple subscribers to receive messages independently. When a message is published to a topic, it is delivered to all subscribers associated with that topic, facilitating an event-driven architecture. Topics help organize and manage message flow in a decoupled manner, making it easier to build scalable applications.
    4
    Click on the **CREATE TOPIC** button
    5
    **Create Topic** wizard will open, give the **Topic ID** as - "**my-first-topic**"
    6
    Scroll to the **Encryption** section and select the option "**Google-managed encryption key**"
    information ordinal icon
    **What is Google-managed encryption key?**\ \ A **Google-managed encryption key** is a cryptographic key that Google Cloud automatically creates and manages for encrypting your data stored in Google Cloud services. This key is used to secure data at rest and is handled entirely by Google, meaning users don't need to manage key lifecycle operations like creation, rotation, or deletion. This simplifies security management while ensuring that data remains protected with robust encryption practices.
    7
    Click on the **CREATE** button
    8
    **my-first-topic** wizard will open, scroll the page and click on the **CREATE SUBSCRIPTION** button
    information ordinal icon
    **What is Subscription?**\ \ A **subscription** in Google Cloud Pub/Sub is a resource that allows subscribers to receive messages from a specific topic. When a subscriber creates a subscription to a topic, it can access messages published to that topic, either by pulling them on demand or by having them pushed automatically. Subscriptions facilitate the delivery of messages to multiple subscribers, enabling decoupled communication between different components of an application.
    9
    **Add subscription to topic** wizard will open, give the **Subscription ID** as - "**subscription-2**"
    10
    Scroll to the **Delivery type** text input field and select the option **Pull**
    information ordinal icon
    **What is Delivery type?**\ \ **Delivery type** in Google Cloud Pub/Sub refers to the method by which messages are delivered to subscribers. There are two main types: 1. **Pull Delivery**: Subscribers explicitly request (or "pull") messages from the subscription. They control when and how many messages to retrieve. 2. **Push Delivery**: Messages are automatically sent ("pushed") to a specified endpoint (like an HTTP callback) as soon as they are published to the topic. Subscribers do not need to request messages; they receive them in real-time. 3. **Write to BigQuery**: This delivery type allows messages published to a Pub/Sub topic to be automatically stored in a BigQuery dataset. This is useful for analytics and reporting, as it enables real-time data ingestion and querying of the data directly from BigQuery. **Write to Cloud Storage**: This option enables messages to be stored in a Cloud Storage bucket. When using this delivery type, messages are saved as files in the specified bucket, making it suitable for archiving, backups, or further processing by other applications or services.\ \ Choosing the delivery type depends on the application's architecture and requirements.
    11
    Scroll to the **Message retention duration** section, here you can configure the retention duration
    information ordinal icon
    **What is Message retention duration?**\ \ **Message retention duration** in Google Cloud Pub/Sub refers to the length of time that published messages are stored in a subscription after they are published. If a message is not acknowledged by a subscriber within this period, it will be deleted. The default retention duration is seven days, but it can be configured to last from 10 minutes to 31 days. This setting helps manage storage costs and ensures that messages are available for subscribers for a specified timeframe.
    12
    Scroll to the **Expiration period** section, here you can configure the Expiration period
    information ordinal icon
    **What is Expiration period?**\ \ **Expiration period** in Google Cloud Pub/Sub refers to the duration after which a subscription or topic is automatically deleted if it is not actively used. For subscriptions, this means that if there are no acknowledged messages or if the subscription is not pulled or pushed for a specified time, it will expire and be removed. This feature helps manage resources by automatically cleaning up unused subscriptions and topics, ensuring efficient resource utilization in the cloud environment.
    13
    Scroll to the **Acknowledgement deadline** section, here you can set the Acknowledgement deadline