Topic properties

Pub/Sub topic properties are the characteristics of a topic. You can set topic properties when you create or update a topic.

This document describes the different topic properties you can set for a topic.

Before you begin

Common topic properties

When you create a topic, you must specify a number of options to set up the topic. Some of these properties are common to all types of topics and are discussed in the next sections.

Add a default subscription

Adds a default subscription to the Pub/Sub topic. You can create another subscription for the topic after the topic is created. The default subscription has the following properties:

  • Subscription ID of -sub
  • Pull delivery type
  • Message retention duration of seven days
  • Expiration after 31 days of inactivity
  • Acknowledgment deadline of 10 seconds
  • Immediate retry policy

Schema

A schema is a format that the message data field must follow. A schema is a contract between the publisher and subscriber that Pub/Sub enforces.

Topic schemas help standardize message types and permissions to allow them to be consumed by different teams in your organization. Pub/Sub creates a central authority for message types and permissions. To create a topic with schema, see Create and manage schemas.

Message retention duration

Specifies how long the Pub/Sub topic retains messages after publication. After the message retention duration is over, Pub/Sub might discard the message regardless of its acknowledgment state. Message storage fees are charged for storing all messages published to the topic.

  • Default = Not enabled
  • Minimum value = 10 minutes
  • Maximum value = 31 days

Use a customer-managed encryption key (CMEK)

Specifies if the topic is encrypted with a CMEK. Pub/Sub encrypts messages with Google-managed keys by default. If you specify this option, Pub/Sub uses the envelope encryption pattern with CMEK. In this approach, Cloud KMS does not encrypt the messages. Instead, Cloud KMS encrypts the Data Encryption Keys (DEKs) that Pub/Sub creates for each topic.

Pub/Sub encrypts the messages using the newest DEK that was generated for the topic. Pub/Sub decrypts the messages shortly before they are delivered to subscribers.

For more information about creating a key, see Configure message encryption.

What's next