Manage Schemas in Confluent Cloud

Schema Management is fully supported on Confluent Cloud with Schema Registry. Details are listed below.

Supported Features and Limits for Confluent Cloud Schema Registry

  • A single Schema Registry is available per Environment.
  • Access Control to Schema Registry is based on API key and secret.
  • Each Environment must have at least one Apache Kafka® cluster to enable Schema Registry.
  • Your VPC must be able to communicate with the Confluent Cloud Schema Registry public internet endpoint. For more information, see Using Confluent Cloud Schema Registry in a VPC Peered Environment.
  • Available on Amazon Web Services (AWS), Azure (Microsoft Azure), and GCP (Google Cloud Platform) for cloud provider geographies located in the US, Europe, and APAC. For each cloud provider, geographies are mapped under the hood to specific regions, as described in Enable Schema Registry for Confluent Cloud.
  • Maximum number of schemas allowed is 1,000.
  • Rate limits on number of API requests is 25 requests per second for each API key.
  • High availability (HA) is achieved by having multiple nodes within a cluster always in running state, with each node running in a different availability zone (AZ).

Working with Schemas

You can manage schemas for topics in Confluent Cloud.

The following sections assume you have Schema Registry enabled. If you are just getting started with schemas, see Quick Start for Schema Management on Confluent Cloud in the quick start to enable Schema Registry and learn more about working with schemas in Confluent Cloud.

Viewing a schema in Confluent Cloud

View the schema details for a specific topic.

  1. If you have more than one environment, select an environment.

    ../_images/cloud-0-environment-select.png

    Tip

    • If you have not explicitly created any new environments, the default environment is automatically selected and the starting page is the cluster list (next step).
    • To view environments, click the hamburger menu top left, and select Environments.
  2. From the Clusters page, click the cluster you want to work with.

    ../_images/cloud-0a-cluster-select.png
  3. From the navigation menu, click Topics, then click a topic to select it.

    ../_images/cloud-01-topic-select.png
  4. Click the Schema tab.

    The Value schema is displayed by default.

    ../_images/cloud-02-view-value-schema.png
  5. Click Key to view the key schema if present.

Creating a topic schema in Confluent Cloud

Create key and value schemas. Value schemas are typically created more frequently than a key schema.

Best practices:

  • Provide default values for fields to facilitate backward-compatibility if pertinent to your schema.
  • Document at least the more obscure fields for human-readability of a schema.

Tip

You can also create schemas from the Confluent Cloud CLI, as described in the Create a Schema section in the Quick Start.

Create a topic value schema

  1. From the navigation menu, click Topics, then click a topic to select it (or create a new one).

  2. Click the Schema tab.

    ../_images/cloud-03-set-msg-value-schema.png
  3. Click Set a schema. The Schema editor appears.

    ../_images/cloud-04-schema-value-editor.png
  4. The basic structure of a schema appears prepopulated in the editor as a starting point. Enter the schema in the editor:

    • name: Enter a name for the schema if you do not want to accept the default, which is determined by the subject name strategy. The default is schema_type_topic_name. Required.

    • type: Either record, enum, union, array, map, or fixed. (The type record is specified at the schema’s top level and can include multiple fields of different data types.) Required.

    • namespace: Fully-qualified name to prevent schema naming conflicts. String that qualifies the schema name. Optional but recommended.

    • fields: JSON array listing one or more fields for a record. Required.

      Each field can have the following attributes:

      • name: Name of the field. Required.
      • type: Data type for the field. Required.
      • doc: Field metadata. Optional but recommended.
      • default: Default value for a field. Optional but recommended.
      • order: Sorting order for a field. Valid values are ascending, descending, or ignore. Default: Ascending. Optional.
      • aliases: Alternative names for a field. Optional.

    For example, you could add the following simple schema.

    {
      "type": "record",
      "name": "value_my_new_widget",
      "fields": [
        {
          "name": "name",
          "type": "string"
        }
      ]
    }
    

    This will display in Confluent Cloud as shown below.

    ../_images/cloud-05-entered-schema.png

    In edit mode, you have options to:

    • Validate the schema for syntax and structure before you create it.
    • Add schema references with a guided wizard.
  5. Click Create.

    • If the entered schema is valid, you can successfully save it and a Schema updated message is briefly displayed in the banner area.

      ../_images/cloud-06-schema-updated.png
    • If the entered schema is invalid, parse errors are highlighted in the editor (as in this example where a curly bracket was left off). If parse errors aren’t auto-highlighted, click the See error messages link on the warning banner to enable them.

      ../_images/cloud-07-schema-invalid-avro.png

If applicable, repeat the procedure as appropriate for the topic key schema.

Working with schema references

You can add a reference to another schema, using the wizard to help locate available schemas and versions.

../_images/cloud-05a-schema-references.png

The Reference name you provide must match the target schema, based on guidelines for the schema format you are using:

  • In JSON Schema, the name is the value on the $ref field of the referenced schema
  • In Avro, the name is the value on the type field of the referenced schema
  • In Protobuf, the name is the value on the Import statement referenced schema

First, locate the schema you want to reference, and get the reference name for it.

Add a schema reference to the current schema in the editor

  1. Click Add reference.
  2. Provide a Reference name per the rules described above.
  3. Select the schema fro the Subject list.
  4. Select the Version of the schema you want to use.
  5. Click Validate to check if the reference will pass.
  6. Click Save to save the reference.

For example, to reference to the schema for the employees topic (employees-value) from the widget schema, you can configure a reference to type, record as shown.

../_images/cloud-05b-schema-references.png

To learn more, see Schema References in the Confluent Platform documentation.

View, edit, or delete schema references for a topic

Existing schema references show up on editable versions of the schema where they are configured.

  1. Navigate to a topic; for example, the widget-value schema associated with the widget topic in the previous example.

  2. Click into the editor as if to edit the schema.

    If there are references to other Schemas configured in this schema, they will display in the Schema references list below the editor.

    You can also add more references to this schema, modify existing, or delete references from this view.

Create a topic key schema

  1. Click the Key option. You are prompted to set a message key schema.

    ../_images/cloud-08-set-msg-key-schema.png
  2. Click Set a schema.

  3. Enter the schema into the editor and click Save.

Tip

Kafka messages are key/value pairs. Message keys and message values can be serialized independently. For example, the value may be using an Avro record, while the key may be a primitive (string, integer, and so forth). Typically message keys, if used, are primitives, but they can be complex data types as well (for example, record or array). How you set the key is up to you and the requirements of your implementation. For detailed examples of key and value schemas, see the discussion under Schema Formats, Serializers, and Deserializers in the Schema Registry documentation.

Editing a schema in Confluent Cloud

Edit an existing schema for a topic.

  1. From the navigation menu, click Topics, then click a topic to select it.

  2. Click the Schema tab.

  3. Select the Key or Value option for the schema.

  4. Make the changes in the schema editor.

    For example, you could edit the previous schema by adding a new field called region.

    {
      "fields": [
        {
          "name": "name",
          "type": "string"
        },
        {
          "name": "region",
          "type": "string",
          "default": ""
        }
      ],
      "name": "value_widgets",
      "type": "record"
    }
    

    In edit mode, you have options to:

    Tip

    When the compatibility mode is set to Backward Compatibility, you must provide a default for the new field. This ensures that consumer applications can read both older messages written to the Version 1 schema (with only a name field) and new messages constructed per the Version 2 schema (with name and region fields). For messages that match the Version 1 schema and only have values for name, region is left empty. To learn more, see Passing Compatibility Checks in the Confluent Cloud Schema Registry Tutorial.

  5. Click Save.

    • If the schema update is valid and compatible with its prior versions (assuming a backward-compatible mode), the schema is updated and the version count is incremented. You can compare the different versions of a schema.

      ../_images/cloud-09-schema-version-updated.png
    • If the schema update is invalid or incompatible with an earlier schema version, parse errors are highlighted in the editor (as in this example where a curly bracket was left off). If parse errors aren’t auto-highlighted, click the See error messages link on the warning banner to enable them.

      For example, if you add a new field but do not include a default value as described in the previous step, you will get an incompatibility error as shown here. You can fix this by adding a default value for “amount”.

      ../_images/cloud-10-schema-incompatible.png

Comparing schema versions in Confluent Cloud

Compare versions of a schema to view its evolutionary differences.

  1. From the navigation menu, click Topics, then click a topic to select it.

  2. Click the Schema tab.

  3. Select the Key or Value option for the schema. (The schema Value is displayed by default.)

    ../_images/cloud-11a-schema-version-newest.png
  4. Click the ellipses (3 dots) on the upper right to get the menu, then select Version history.

    ../_images/cloud-11b-schema-version-history-choose.png
  5. Click Version history.

    ../_images/cloud-11-schema-version-history.png

    The current version number of a schema displays in the upper-right corner of the Schema pane, and is also indicated in the version menus.

  6. Select the Turn on version diff check box.

  7. Select the versions to compare from each version menu. The differences are highlighted for comparison.

    ../_images/cloud-12-schema-compare.png

Changing the compatibility mode of a schema in Confluent Cloud

The default compatibility mode is Backward. The mode can be changed for the schema of any topic if necessary.

Caution

If you change the compatibility mode of an existing schema already in production use, be aware of any possible breaking changes to your applications.

  1. Select an environment.

  2. Click the Settings tab.

  3. Click Schema Registry compatibility configuration to expand the compatibility options.

  4. From the navigation menu, click Topics, then click a topic to select it.

  5. Click the Schema tab.

  6. Select the Key or Value option for the schema.

  7. Click Edit Schema -> Compatibility Mode tab.

    ../_images/cloud-13-schema-compat-mode.png
  8. Select a mode option:

    Descriptions indicate the compatibility behavior for each option. For more information, including the changes allowed for each option, see Schema Evolution and Compatibility.

  9. Click Save.

Downloading a schema from Confluent Cloud

  1. From the navigation menu, click Topics, then click a topic to select it.

  2. Click the Schema tab.

  3. Select the Key or Value option for the schema.

  4. Click Download. A schema JSON file for the topic is downloaded into your Downloads directory.

    Example filename: schema-transactions-v1-Ry_XaOGvTxiZVZ5hbBhWRA.json

    Example contents:

    {"subject":"transactions-value","version":1,"id":2,"schema":"{\"type\":\"record\",\"name\":\"Payment\",
    \"namespace\":\"io.confluent.examples.clients.basicavro\",
    \"fields\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"amount\",\"type\":\"double\"},
    {\"name\":\"region\",\"type\":\"string\"}]}"}
    

    This is the first version of the schema, and it has an id of 2. The schema is escaped JSON. A backslash precedes double-quotes.

Tip

The file extension indicates the schema format. For Avro schema the file extension is .avsc; for Protobuf schema, .proto; and for JSON Schema, .json.

Managing Schemas for an Environment

Schema Registry itself sits at the environment level and serves all clusters in an environment, therefore several tasks related to schemas are managed through the registry at this level.

To view and manage Schema Registry for a Confluent Cloud environment:

  1. Select an environment from the Home page. (An environment list is available from the top right menu.)

  2. Click the Schema Registry tab.

    Screenshot of Schema Registry settings

See Configure and Manage Schemas for an Environment in the Confluent Cloud Quick Start to learn how to: