Event Data Serialization with Apache Avro

Pub/Sub API publishes and delivers binary-encoded events with payloads encoded in the Apache Avro schema. Apache Avro is a data serialization system that provides a binary or JSON data encoding and a schema. The Avro binary encoding is more efficient than the Avro JSON encoding because it enables faster serialization and produces smaller sizes of serialized data. For more information, see Data Serialization and Deserialization in the Apache Avro specification.

When sending or receiving events from the Pub/Sub API, your app must use Apache Avro to serialize and deserialize event payloads. Before you publish an event message, encode it to the Avro format. And when you receive an event message, decode it using the Avro format before you can retrieve the contents of the event payload. For more information, see Pub/Sub API as a gRPC API and the Apache Avro Documentation. The Python Quick Start for Pub/Sub API includes example functions for encoding and decoding the event messages using Avro.

See Also