0
0
Kafkadevops~30 mins

Schema Registry concept in Kafka - Mini Project: Build & Apply

Choose your learning style9 modes available
Schema Registry Concept with Kafka
📖 Scenario: You are working with Kafka to send messages between services. To keep data consistent, you use a Schema Registry that stores the structure of your messages. This helps producers and consumers agree on the data format.
🎯 Goal: Learn how to register a schema, configure a Kafka producer to use the Schema Registry, and produce a message that follows the schema.
📋 What You'll Learn
Create a schema definition in JSON format
Set a variable for the Schema Registry URL
Configure a Kafka producer to use the Schema Registry
Produce a message that matches the schema
Print the confirmation of message sent
💡 Why This Matters
🌍 Real World
Schema Registry ensures that all services agree on the data format, preventing errors and data corruption in distributed systems.
💼 Career
Understanding Schema Registry is essential for roles involving Kafka, data pipelines, and event-driven architectures.
Progress0 / 4 steps
1
Create the JSON schema definition
Create a variable called user_schema and assign it this exact JSON string representing a user schema: {"type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"age","type":"int"}]}
Kafka
Need a hint?

Use single quotes outside and double quotes inside the JSON string.

2
Set the Schema Registry URL
Create a variable called schema_registry_url and set it to the string "http://localhost:8081"
Kafka
Need a hint?

Use double quotes for the URL string.

3
Configure Kafka producer with Schema Registry
Create a dictionary called producer_config with keys "bootstrap.servers" set to "localhost:9092" and "schema.registry.url" set to the variable schema_registry_url
Kafka
Need a hint?

Use curly braces to create the dictionary and include the exact keys and values.

4
Produce a message and print confirmation
Write a print statement that outputs exactly "Message sent with schema User"
Kafka
Need a hint?

Use the print function with the exact string inside double quotes.