Google Cloud PubSub Operators¶
Google Cloud PubSub is a fully-managed real-time messaging service that allows you to send and receive messages between independent applications. You can leverage Cloud Pub/Sub’s flexibility to decouple systems and components hosted on Google Cloud or elsewhere on the Internet.
Publisher applications can send messages to a topic and other applications can subscribe to that topic to receive the messages. By decoupling senders and receivers Google Cloud PubSub allows developers to communicate between independently written applications.
Creating a PubSub topic¶
The PubSub topic is a named resource to which messages are sent by publishers.
The PubSubCreateTopicOperator
operator creates a topic.
Creating a PubSub subscription¶
A Subscription
is a named resource representing the stream of messages from a single, specific topic,
to be delivered to the subscribing application.
The PubSubCreateSubscriptionOperator
operator creates the subscription.
Publishing PubSub messages¶
A Message
is a combination of data and (optional) attributes that a publisher sends to a topic and is eventually delivered to subscribers.
The PubSubPublishMessageOperator
operator would publish messages.
Pulling messages from a PubSub subscription¶
The PubSubPullSensor
sensor pulls messages from a PubSub subscription
and pass them through XCom.
To pull messages from XCom use the BashOperator
.
Deleting a PubSub subscription¶
The PubSubDeleteSubscriptionOperator
operator deletes the subscription.
Deleting a PubSub topic¶
The PubSubDeleteTopicOperator
operator deletes topic.