Skip to content

Google Pub/Sub Channel Binding v0.2.0

The Google Cloud Pub/Sub channel binding defines how an AsyncAPI channel maps to a Google Cloud Pub/Sub Topic.

Overview

This binding object allows you to specify detailed configuration for a Pub/Sub topic, including its labels, message storage policies, and schema validation settings.

Channel Properties

PropertyTypeRequiredDescription
bindingVersionstringNoBinding version (defaults to 0.2.0).
labelsobjectNoA map of key-value pairs that can be used to organize Pub/Sub resources.
messageRetentionDurationstringNoThe minimum duration (in seconds, with an "s" suffix) that a message is retained after publication.
messageStoragePolicyobjectNoPolicy for controlling where messages are stored.
schemaSettingsobjectYesSettings for a schema that the topic is associated with.

messageStoragePolicy Object

PropertyTypeRequiredDescription
allowedPersistenceRegionsarrayYesA list of GCP region IDs where messages may be stored.

schemaSettings Object

PropertyTypeRequiredDescription
encodingstringYesThe encoding of messages validated against the schema. Can be json or binary.
namestringYesThe full resource name of the schema in the format projects/{project}/schemas/{schema}.
firstRevisionIdstringNoThe first revision ID of the schema definition.
lastRevisionIdstringNoThe last revision ID of the schema definition.

Example

Topic with Schema Validation and Storage Policy

This example defines a channel that maps to a Pub/Sub topic. It requires that all messages conform to a specific JSON schema and ensures that message data is only stored in us-central1 and us-east1.

yaml
channels:
  user-creation-events:
    address: 'user-created-topic'
    bindings:
      googlepubsub:
        bindingVersion: '0.2.0'
        labels:
          owner: 'auth-team'
        messageRetentionDuration: '86400s' # 1 day
        messageStoragePolicy:
          allowedPersistenceRegions:
            - 'us-central1'
            - 'us-east1'
        schemaSettings:
          encoding: 'json'
          name: 'projects/my-gcp-project/schemas/UserCreatedEvent'

Changelog

Version 0.2.0

  • Added the schemaSettings object to enforce schema validation on topics.
  • The schema property from v0.1.0 was removed and replaced by schemaSettings.