
PubSubPullOperator
Created by
Airflow Community
Version
Pulls messages from a PubSub subscription and passes them through XCom.
Parameters
project_id
strREQUIRED
project_id
strREQUIREDthe Google Cloud project ID for the subscription (templated)
subscription
strREQUIRED
subscription
strREQUIREDthe Pub/Sub subscription name. Do not include the full subscription path.
max_messages
int
max_messages
intThe maximum number of messages to retrieve per PubSub pull request
ack_messages
bool
ack_messages
boolIf True, each message will be acknowledged immediately rather than by any downstream tasks
messages_callback
Callable[[list[ReceivedMessage], Context], Any] | None
messages_callback
Callable[[list[ReceivedMessage], Context], Any] | None(Optional) Callback to process received messages. Its return value will be saved to XCom. If you are pulling large messages, you probably want to provide a custom callback. If not provided, the default implementation will convert ReceivedMessage objects into JSON-serializable dicts using google.protobuf.json_format.MessageToDict function.
gcp_conn_id
str
gcp_conn_id
strThe connection ID to use connecting to Google Cloud.
impersonation_chain
str | Sequence[str] | None
impersonation_chain
str | Sequence[str] | NoneOptional service account to impersonate using short-term credentials, or chained list of accounts required to get the access_token of the last account in the list, which will be impersonated in the request. If set as a string, the account must grant the originating account the Service Account Token Creator IAM role. If set as a sequence, the identities from the list must grant Service Account Token Creator IAM role to the directly preceding identity, with first account from the list granting this role to the originating account (templated).
deferrable
bool
deferrable
boolIf True, run the task in the deferrable mode.
poll_interval
int
poll_interval
intTime (seconds) to wait between two consecutive calls to check the job. The default is 300 seconds.
Documentation
Pulls messages from a PubSub subscription and passes them through XCom.
If the queue is empty, returns empty list - never waits for messages. If you do need to wait, please use airflow.providers.google.cloud.sensors.PubSubPullSensor
instead.
See also
For more information on how to use this operator and the PubSubPullSensor, take a look at the guide: Pulling messages from a PubSub subscription
This operator will pull up to max_messages
messages from the specified PubSub subscription. When the subscription returns messages, the messages will be returned immediately from the operator and passed through XCom for downstream tasks.
If ack_messages
is set to True, messages will be immediately acknowledged before being returned, otherwise, downstream tasks will be responsible for acknowledging them.
project_id `` and ``subscription
are templated so you can use Jinja templating in their values.