apache_beam.io.gcp.pubsub module¶
Google Cloud PubSub sources and sinks.
Cloud Pub/Sub sources and sinks are currently supported only in streaming pipelines, during remote execution.
This API is currently under development and is subject to change.
- Description of common arguments used in this module:
- topic: Cloud Pub/Sub topic in the form “projects/<project>/topics/<topic>”.
- If provided, subscription must be None.
- subscription: Existing Cloud Pub/Sub subscription to use in the
- form “projects/<project>/subscriptions/<subscription>”. If not specified, a temporary subscription will be created from the specified topic. If provided, topic must be None.
-
class
apache_beam.io.gcp.pubsub.
PubsubMessage
(payload, attributes)[source]¶ Bases:
future.types.newobject.newobject
Represents a message from Cloud Pub/Sub.
This interface is experimental. No backwards compatibility guarantees.
-
payload
¶ (str) Message payload, as a byte string.
-
attributes
¶ (dict) Map of string to string.
Constructs a message.
Beam users should not directly construct
PubsubMessages
.-
-
class
apache_beam.io.gcp.pubsub.
ReadFromPubSub
(topic=None, subscription=None, id_label=None, timestamp_attribute=None)[source]¶ Bases:
apache_beam.transforms.ptransform.PTransform
A
PTransform
for reading from Cloud Pub/Sub.Initializes
ReadFromPubSub
.Parameters: - id_label – The attribute on incoming Pub/Sub messages to use as a unique record identifier. When specified, the value of this attribute (which can be any string that uniquely identifies the record) will be used for deduplication of messages. If not provided, we cannot guarantee that no duplicate data will be delivered on the Pub/Sub stream. In this case, deduplication of the stream will be strictly best effort.
- timestamp_attribute –
Message value to use as element timestamp. If None, uses message publishing time as the timestamp.
Timestamp values should be in one of two formats:
- A numerical value representing the number of milliseconds since the Unix epoch.
- A string in RFC 3339 format, UTC timezone. Example:
2015-10-29T23:41:41.123Z
. The sub-second component of the timestamp is optional, and digits beyond the first three (i.e., time units smaller than milliseconds) may be ignored.
-
class
apache_beam.io.gcp.pubsub.
ReadStringsFromPubSub
(topic=None, subscription=None, id_label=None)[source]¶ Bases:
apache_beam.transforms.ptransform.PTransform
A
PTransform
for reading utf-8 string payloads from Cloud Pub/Sub.Outputs elements of type
unicode
, decoded from UTF-8.This class is deprecated.
-
class
apache_beam.io.gcp.pubsub.
WriteStringsToPubSub
(topic)[source]¶ Bases:
apache_beam.transforms.ptransform.PTransform
A
PTransform
for writing utf-8 string payloads to Cloud Pub/Sub.Initializes
WriteStringsToPubSub
.-
topic
¶ Cloud Pub/Sub topic in the form “/topics/<project>/<topic>”.
-