Todas as amostras de código do Pub/Sub Lite

This page contains code samples for Pub/Sub Lite. To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.

Create Lite subscription

Create a Lite subscription with a chosen delivery mode.

Create Lite topic

Create a single-partition Lite topic and configure its retention period, per partition storage, and publishing throughput scaling factor.

View in documentation

Delete Lite subscription

Delete a Lite subscription.

Delete Lite topic

Delete a Lite topic.

View in documentation

Get Lite subscription

Print name, topic path, and delivery config of a Lite subscription.

Get Lite topic

Print name, retention config, and partition config of a Lite topic.

View in documentation

List Lite subscriptions in project

List Lite subscriptions in a project.

List Lite subscriptions in topic

List Lite subscriptions in a Lite topic.

List Lite topics

List Lite topics in a project.

View in documentation


Publish messages to a single-partition Lite topic and resolve the publish futures asynchronously.

Publish messages from Apache Kafka

Publish messages to a Pub/Sub Lite topic using a shim for the Kafka Producer API

Publish with batch settings

Publish messages with batch settings.

View in documentation

Publish with custom attributes

Publish messages with custom attributes.

View in documentation

Publish with ordering keys

Publish messages with an ordering key. Ordering keys are hashed to map to a partition. Messages of the same ordering key get published to the same partition. If the partition is filled up, oldest messages get written over.

View in documentation

Receive messages in Apache Kafka

Receive messages from a Pub/Sub Lite subscription using a shim for the Kafka Consumer API

Stream Pub/Sub Lite to Cloud Storage using Dataflow

This sample shows how to create an Apache Beam streaming pipeline that reads messages from Pub/Sub Lite, group the messages using a fixed-sized windowing function, and writes them to Cloud Storage.

View in documentation


Use a multi-partition and flow-controlled subscriber (a collection of subscribers) to subscribe to a multiple-partition topic and process messages asynchronously in callbacks.

Update Lite subscription

Update the delivery mode of a Lite subscription.

Update Lite topic

Update the retention period, the scaling factor (throughput capacity), and per partition bytes (storage capacity) of a Lite topic.

View in documentation