Kafka Source Connector
Debezium
JSON schema
Data Management
IT Solutions

How to disable JSON schema in Kafka Source Connector (e.g. Debezium)

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Apache Kafka, a distributed event-streaming platform, has gained immense popularity for its robust performance in handling real-time data streams. Debezium, an open-source distributed platform, provides connectors that integrate various databases into Kafka. These connectors typically use JSON schemas to describe the structure of each message that gets published to a Kafka topic. Sometimes, however, you might want to simplify the messages and exclude these schemas. Disabling JSON schema can be beneficial for certain use cases, such as reducing message size or when schema validation is handled externally.

Understanding JSON Schema in Kafka Connect

JSON schemas in Kafka Connect describe the structure, format, and type of each field in a message. This metadata facilitates applications and services to interpret data correctly and ensures compatibility between systems. The schema is usually included in each message payload, allowing consumers to deserialize and process data correctly.

Disabling JSON Schema in Debezium Connectors

Debezium connectors, which capture database changes, typically emit messages that include JSON schemas. However, Debezium allows you to configure connectors to disable schema propagation. This results in publishing only the raw data payload, without accompanying schema information.

Step-by-Step Guide:

  1. Install and Set Up Kafka and Debezium: Ensure both Apache Kafka and Debezium are correctly installed and configured. You usually need Zookeeper, Kafka Broker, and Kafka Connect.
  2. Configure Kafka Connect: When setting up your Debezium connector, modify the connector configuration. Key configurations to adjust include:
    • key.converter: Determines how message keys are serialized. Set this to org.apache.kafka.connect.json.JsonConverter.
    • value.converter: Determines how message bodies are serialized. Also, set this to org.apache.kafka.connect.json.JsonConverter.
    • key.converter.schemas.enable: Set this to false to disable schema information on the message key.
    • value.converter.schemas.enable: Set this to false to disable schema information on the message value.

Here is a sample configuration snippet for disabling the schema in a Debezium connector:

properties
1# Kafka Connect properties
2key.converter=org.apache.kafka.connect.json.JsonConverter
3value.converter=org.apache.kafka.connect.json.JsonConverter
4key.converter.schemas.enable=false
5value.converter.schemas.enable=false
  1. Deploy the Connector: Utilize the Kafka Connect REST API or any UI tools to deploy your configured connector.

Impact of Disabling JSON Schema

Disabling JSON schema has significant implications:

  • Message size: The overall size of each Kafka message is reduced as the schema part is omitted.
  • Flexibility: Consumers of the messages need to know the schema by other means or be able to handle schema-less data.
  • Compatibility: Downstream systems need explicit coordination on data structure and updates.

Summary Table

Configuration PropertyValueDescription
key.converterorg.apache.kafka.connect.json.JsonConverterSpecifies the converter class for key serialization.
value.converterorg.apache.kafka.connect.json.JsonConverterSpecifies the converter class for value serialization.
key.converter.schemas.enablefalseDisables the inclusion of schema in the key.
value.converter.schemas.enablefalseDisables the inclusion of schema in the value.

Conclusion

Disabling JSON schema in Debezium connectors can be useful to reduce payload size and simplify message structure. However, it requires careful consideration of how data will be interpreted by consuming applications and how changes in data structure will be managed.

Additional Considerations

  • Schema Management: When schema is disabled, consider using external tools for schema management, such as Apache Avro with a Schema Registry.
  • Data Quality: Monitor the impact on data integrity and quality checks, since lack of schema could lead to inconsistencies.

Disabling schema propagation simplifies the data but requires a clear strategy on how the schema-less data will be managed effectively across different systems.


Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.