Google Cloud Pub Sub Cloud Pub/Sub Overview

preview_player
Показать описание
GCP Cloud Pub Sub
#GCP #china #USA
Cloud Pub/Sub Overview
Cloud PubSub is a managed processing queue/messaging service which works on the Publisher and Subscriber model. A publisher publishes the message to a particular topic and all the subscribers which are subscribed to that topic receive the message until the acknowledgment is not sent.

PubSub guarantees that message will be sent to the subscribers at least once. You can consider PubSub as an alternative to Apache Kafka which is an open-source alternative.

Introduction
The PubSub is used to decouple services from each other and enable them to scale independently. The services can communicate with each other using the queue and send updates to all other services which are dependent on them.

Apart from this, PubSub can also be used to gather real-time data from different IoT devices and push it to BigQuery for analysis. The Cloud PubSub is integrated with most of the GCP services by default. You can easily access the integration on the home page of the service itself. But for now, we will focus on Cloud PubSub only.

Let’s understand the PubSub workflow in detail.

Working
Cloud PubSub architecture has 6 components.

Topic: Logical queue which acts as an interface between subscribers and publishers. The topic is a way to logically organize the communication channel between subscribers and publishers.

For example, We can have a topic named “Music” where all the music-related messages are published. If any subscriber wants to get updates related to the music only, then it can subscribe to that channel/topic.

Publisher: In the pub-sub architecture, the first part pub stands for the publisher. The Publisher is something that sends out messages to the queue. It can be any HTTP client that can make HTTP requests to send messages to the queue.

Subscription: A named resource representing the stream of messages from a single, specific topic, to be delivered to the subscribing application. A subscriber can be any application that can use the messages to perform some action. subscribes to the subscription to receive messages.

The subscription is the only interface to consume messages. There will be only one topic for each subscription.
Message: The combination of data and optional attributes that a publisher sends to a topic and is eventually delivered to subscribers.

Message attribute: A key-value pair that a publisher can define for a message. You can also consider this as metadata for messages. For example, key language_tag and value en could be added to messages to mark them as readable by an English-speaking subscriber.

Subscriber: The subscriber is any application that subscribes to the topic using subscription. A subscriber can use more than one subscription to receive messages from more than one topic. Also, there can be more than one subscriber-specific to each topic as well. The implementation depends on the business logic.

Let’s explore more about Cloud PubSub.

The message delivery is totally dependant on the type of subscription used. The Cloud PubSub provides 2 types of message deliveries based on the subscription types.

Pull Subscription: When the pull method of message delivery is used, you need to create a pull subscription, the subscriber needs to requests upcoming messages using that subscription. Either subscriber can continuously poll for incoming messages or use periodic pulls.

Push: When the push method of message delivery is used, you need to specify one publicly accessible HTTPS endpoint. The messages are delivered to that endpoint using an HTTP request. The delivery of messages is immediate.

The message delivery is totally dependant on the type of subscription used. The Cloud PubSub provides 2 types of message deliveries based on the subscription types.

Pull Subscription: When the pull method of message delivery is used, you need to create a pull subscription, the subscriber needs to requests upcoming messages using that subscription. Either subscriber can continuously poll for incoming messages or use periodic pulls.

Push: When the push method of message delivery is used, you need to specify one publicly accessible HTTPS endpoint. The messages are delivered to that endpoint using an HTTP request. The delivery of messages is immediate.
Рекомендации по теме