Exploring Google Cloud Pub/Sub message schemas

Pavan Kumar Kattamuri
2 min readMar 13, 2021

--

Google Cloud Pub/Sub recently launched message schemas in Preview Launch stage on 1st March 2021. Let’s explore it’s current capabilities and nice to have features

What it is?

It helps you to do a fixed schema validation on the message before it is inserted into your Pub/Sub topic. If schema compliance check passes, it gets published to the topic else it won’t make it to the topic

Steps to create schema and enforce it on a topic

  • Define/Create a schema in either AVRO/Protobuf format
  • Optionally, you can do message validation before proceeding with topic creation
  • Create a PubSub topic and while creating the topic, associate the schema to be enforced
  • Publish messages to the topic. In the screenshot below you can see both a valid message being published to the topic and an invalid message being rejected
  • Same happens when you publish an invalid message from the console stating the reason “Request contains an invalid argument”

Deleting a schema in-use

Publishing to the associated topic(s) will fail if you delete a schema in between with the error ‘Resource not found’

Current capabilities

  • Fixed schema validation of messages going into Pub/Sub topic
  • Associating a schema with multiple Pub/Sub topics

Features not available currently

  • Associating schema to existing topics
  • Updating schema once it’s created
  • No versioning/tracking
  • Schema evolution is not possible as of today

Though this doesn’t have lot of necessary features like schema updation/evolution, this looks like a first step towards schema registry/enforcement and hope Google releases more such features to have a cloud native solution in Pub/Sub.

--

--

Pavan Kumar Kattamuri
Pavan Kumar Kattamuri

Written by Pavan Kumar Kattamuri

Platform Engineer | Cloud | GCP | AWS

No responses yet