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.
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:
- 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.
- 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 toorg.apache.kafka.connect.json.JsonConverter.value.converter: Determines how message bodies are serialized. Also, set this toorg.apache.kafka.connect.json.JsonConverter.key.converter.schemas.enable: Set this tofalseto disable schema information on the message key.value.converter.schemas.enable: Set this tofalseto disable schema information on the message value.
Here is a sample configuration snippet for disabling the schema in a Debezium connector:
- 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 Property | Value | Description |
key.converter | org.apache.kafka.connect.json.JsonConverter | Specifies the converter class for key serialization. |
value.converter | org.apache.kafka.connect.json.JsonConverter | Specifies the converter class for value serialization. |
key.converter.schemas.enable | false | Disables the inclusion of schema in the key. |
value.converter.schemas.enable | false | Disables 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
- How to disable RabbitMQ default tcp listening port - 5672
- How to do content filtering with Apache Kafka?
- How to do error handling with EasyNetQ / RabbitMQ
- How to dynamically add consumers in consumer group kafka
- How to Dynamodb send message to SQS
- How to efficiently compute average on the fly moving average?
- How to efficiently create Kafka topics with testcontainers?
- how to efficiently merge int ranges in a stream?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack 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.