{"id":1022,"date":"2024-05-17T11:10:12","date_gmt":"2024-05-17T04:10:12","guid":{"rendered":"https:\/\/thoaicoder.com\/?p=1022"},"modified":"2024-07-23T01:31:30","modified_gmt":"2024-07-22T18:31:30","slug":"kafka-part-2-schema-registry","status":"publish","type":"post","link":"https:\/\/thoaicoder.com\/index.php\/2024\/05\/17\/kafka-part-2-schema-registry\/","title":{"rendered":"Kafka (Part 2) &#8211; Schema Registry"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">1. Introduction<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">In the previous article <a href=\"https:\/\/thoaicoder.com\/index.php\/2024\/04\/16\/kafka-in-nutshell\/\">Kafka (Part 1) \u2013 Introduction<\/a> we have walked through Kafka&#8217;s basic concepts with a sample project to demonstrate topics, message keys, and consumer groups using Spring Cloud Stream. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Within this project, the producer and consumer interact via the &#8220;Order&#8221; message which contains two fields: <em>id <\/em>and <em>customerId<\/em>, and is serialized via <strong>JsonSerializer<\/strong>, this approach works well in the scope of our project but in real work there will be many potential scenarios we need to take into account:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Backward\/<strong>Forward<\/strong> Compatibility<\/strong>: one day the business asks us to add one more field to the &#8220;Order&#8221; information such as &#8220;<em>customerName<\/em>&#8220;, hence we need to ensure the new version of the Order schema can still read data written with older versions, and the older versions can also read data written with newer versions.<\/li>\n\n\n\n<li><strong>Data Validation<\/strong>: in case the Order schema is complex, we may need a big effort to handle data validation to prevent corrupted or invalid data.<\/li>\n\n\n\n<li><strong>Centralized Schema Management<\/strong>: if many services produce\/consume Order messages, we will need a centralized repository for managing schemas, which simplifies schema distribution and version control instead of implementing the schema serialization\/deserialization and data validation at each service.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Kafka Schema Registry is the solution we need to deal with the above scenario which is a centralized service that manages and enforces data schemas for messages in Apache Kafka. It ensures that data produced to and consumed from Kafka topics adheres to defined schemas, supporting formats like Avro, Protobuf, and JSON Schema (we will use Avro in this topic &#8211; the most popular format).<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"872\" height=\"434\" src=\"https:\/\/thoaicoder.com\/wp-content\/uploads\/2024\/05\/image.png\" alt=\"\" class=\"wp-image-1054\" srcset=\"https:\/\/thoaicoder.com\/wp-content\/uploads\/2024\/05\/image.png 872w, https:\/\/thoaicoder.com\/wp-content\/uploads\/2024\/05\/image-300x149.png 300w, https:\/\/thoaicoder.com\/wp-content\/uploads\/2024\/05\/image-768x382.png 768w\" sizes=\"auto, (max-width: 872px) 100vw, 872px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The Schema Registry enables schema evolution with compatibility checks, ensuring that new schema versions are compatible with existing ones, thus maintaining data integrity and preventing corruption. It facilitates efficient serialization and deserialization of messages, making it crucial for applications that require robust data validation and schema management.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">2.  Avro Schema and Confluent Schema Registry<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">An Avro schema is a blueprint that defines the structure of data in Apache Avro, a data serialization system. It specifies the fields, their types, and any nesting or complex structures within the data. Avro schemas are written in JSON format and are used for data validation, serialization, and deserialization in Avro-based systems. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the previous article, we use Order POJO to store Order messages which can be converted to Avro schema as below. In this article, we use <a href=\"https:\/\/github.com\/davidmc24\/gradle-avro-plugin?tab=readme-ov-file\">gradle-avro-plugin<\/a> to convert the Order avro file back to Java class.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Order.java<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-tangaroa-background-color has-text-color has-background has-link-color wp-elements-1\" style=\"padding-top:var(--wp--preset--spacing--40);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--40)\"><code>public class Order implements Serializable {\n  private Integer id;\n  private Integer customerId;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">order.avsc<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-tangaroa-background-color has-text-color has-background has-link-color wp-elements-2\" style=\"padding-top:var(--wp--preset--spacing--40);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--40)\"><code>{\n  \"type\": \"record\",\n  \"name\": \"Order\",\n  \"namespace\": \"com.thoainguyen.kafka.schema\",\n  \"fields\": &#91;\n    {\n      \"name\": \"id\",\n      \"type\": \"int\"\n    },\n    {\n      \"name\": \"customerId\",\n      \"type\": \"int\"\n    }\n  ]\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Confluent Schema Registry developed by Confluent, is one such popular implementation of schema registry used widely with Kafka for managing schemas used in Apache Kafka-based data pipelines. It ensures data compatibility and consistency by storing and validating Avro schemas, enabling versioning and evolution of schemas over time via REST API. For example, we can register Order schema and then retrieve it with REST API calls.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Register Order subject<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-white-color has-tangaroa-background-color has-text-color has-background has-link-color wp-elements-3\" style=\"padding-top:var(--wp--preset--spacing--40);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--40)\"><code>curl --location --request POST 'http:\/\/localhost:8081\/subjects\/com.thoainguyen.kafka.schema.Order\/versions' \\\n--header 'Content-Type: application\/vnd.schemaregistry.v1+json' \\\n--data-raw '{\n    \"schema\": \"{\\\"type\\\":\\\"record\\\",\\\"name\\\":\\\"Order\\\",\\\"namespace\\\":\\\"com.thoainguyen.kafka.schema\\\",\\\"fields\\\":&#91;{\\\"name\\\":\\\"id\\\",\\\"type\\\":\\\"int\\\"},{\\\"name\\\":\\\"customerId\\\",\\\"type\\\":\\\"int\\\"}]}\"\n}'<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Retrieve Order subject<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-white-color has-tangaroa-background-color has-text-color has-background has-link-color wp-elements-4\" style=\"padding-top:var(--wp--preset--spacing--40);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--40)\"><code>curl --location --request GET 'http:\/\/localhost:8081\/subjects\/com.thoainguyen.kafka.schema.Order\/versions\/latest'<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">3. Demonstration<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">We will apply Confulence Schema Registry to the Order Management system that we implemented in the <a href=\"https:\/\/thoaicoder.com\/index.php\/2024\/04\/16\/kafka-in-nutshell\/\">Kafka (Part 1)<\/a> topic containing three services: Checkout Service, Order Service, and Fulfillment Service.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"258\" src=\"https:\/\/thoaicoder.com\/wp-content\/uploads\/2024\/05\/anh-1024x258.png\" alt=\"\" class=\"wp-image-978\" srcset=\"https:\/\/thoaicoder.com\/wp-content\/uploads\/2024\/05\/anh-1024x258.png 1024w, https:\/\/thoaicoder.com\/wp-content\/uploads\/2024\/05\/anh-300x75.png 300w, https:\/\/thoaicoder.com\/wp-content\/uploads\/2024\/05\/anh-768x193.png 768w, https:\/\/thoaicoder.com\/wp-content\/uploads\/2024\/05\/anh-1536x386.png 1536w, https:\/\/thoaicoder.com\/wp-content\/uploads\/2024\/05\/anh-2048x515.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">3.1. Build up Conflunce Schema Registry<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Add a schema-registry image to the docker-compose file and configure it to communicate with the kafka broker kafka:29092, we also need to expose its 8081 port which will be used by our application to interact with registered schema via REST API.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>docker-compose.yml<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-tangaroa-background-color has-text-color has-background\" style=\"padding-top:var(--wp--preset--spacing--40);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--40)\"><code>...\nschema-registry:\n    image: confluentinc\/cp-schema-registry:latest\n    hostname: schema-registry\n    container_name: schema-registry\n    depends_on:\n      - kafka\n    ports:\n      - \"8081:8081\"\n    environment:\n      SCHEMA_REGISTRY_HOST_NAME: schema-registry\n      SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS: 'kafka:29092'\n      SCHEMA_REGISTRY_LISTENERS: http:\/\/0.0.0.0:8081<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">3.2. Define schema<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In the previous article, we used <strong>customerId <\/strong>as the message key to ensure all events related to the same customer are processed sequentially by assigning them to the same partition, we also need to define a <strong>OrderKey <\/strong>schema to store this key beside the <strong>Order <\/strong>schema and register it to the Schema Registry:<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-tangaroa-background-color has-text-color has-background has-link-color wp-elements-5\" style=\"padding-top:var(--wp--preset--spacing--40);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--40)\"><code>curl --location --request POST 'http:\/\/localhost:8081\/subjects\/com.thoainguyen.kafka.schema.OrderKey?normalize=false&amp;deleted=false' \\\n--header 'Content-Type: application\/json' \\\n--data-raw '{\"schema\":\"{\\\"type\\\":\\\"record\\\",\\\"name\\\":\\\"OrderKey\\\",\\\"namespace\\\":\\\"com.thoainguyen.kafka.schema\\\",\\\"fields\\\":&#91;{\\\"name\\\":\\\"customerId\\\",\\\"type\\\":\\\"int\\\"}]}\"}'<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now, we have two registered schemas, we can check them by calling the get subjects API of Confulence Schema Registry:<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-tangaroa-background-color has-text-color has-background has-link-color wp-elements-6\" style=\"padding-top:var(--wp--preset--spacing--40);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--40)\"><code>curl --location --request GET 'http:\/\/localhost:8081\/subjects'<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code has-white-color has-tangaroa-background-color has-text-color has-background has-link-color wp-elements-7\" style=\"padding-top:var(--wp--preset--spacing--40);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--40)\"><code>&#91;\n    \"com.thoainguyen.kafka.schema.Order\",\n    \"com.thoainguyen.kafka.schema.OrderKey\"\n]<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">3.3. Add needed dependencies to the client application<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><em>build.gradle<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-tangaroa-background-color has-text-color has-background\" style=\"padding-top:var(--wp--preset--spacing--40);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--40)\"><code>plugins {\n\t....\n\tid \"com.github.davidmc24.gradle.plugin.avro\" version \"1.9.0\" (1)\n}\n...\ndependencies {\n\t...\n\timplementation 'io.confluent:kafka-avro-serializer:7.6.0' (2)\n\timplementation 'org.apache.avro:avro:1.11.0' (3)\n}<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li>A Gradle plugin to allow easy performing Java code generation for Apache Avro<\/li>\n\n\n\n<li>3. Kafka Avro Serializer<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">3.4. Update consumer\/producer serde<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Our Spring application which is using Spring Cloud to streamline the communication with Kafka need to be updated to integrate with the Schema Registry.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>application.yml<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-tangaroa-background-color has-text-color has-background\" style=\"padding-top:var(--wp--preset--spacing--40);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--40)\"><code>...\nspring:\n  cloud:\n    function:\n      definition: consumeOrderCreated;consumeOrderProcessed\n    stream:\n      kafka:\n        binder:\n          brokers: localhost:9092\n        bindings:\n          # checkout service to produce orderCreated message\n          produceOrderCreated-out-0:\n            producer:\n              configuration:\n                key.serializer: io.confluent.kafka.serializers.KafkaAvroSerializer (1)\n                value.serializer: io.confluent.kafka.serializers.KafkaAvroSerializer (2)\n                key.subject.name.strategy: io.confluent.kafka.serializers.subject.RecordNameStrategy (3)\n                value.subject.name.strategy: io.confluent.kafka.serializers.subject.RecordNameStrategy (4)\n                schema.registry.url: http:\/\/localhost:8081 (5)\n                specific.avro.reader: true (6)\n                auto.register.schemas: false (7)\n          ....\n      bindings:\n        produceOrderCreated-out-0:\n          destination: orderCreatedTopic\n          content-type: application\/*+avro (8)\n          producer:\n            use-native-encoding: true\n       ....\n...<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Change key serializer from <strong>StringSerializer <\/strong>to <strong>KafkaAvroSerializer <\/strong><\/li>\n\n\n\n<li>Change value serializer from <strong>JsonSerializer <\/strong>to <strong>KafkaAvroSerializer <\/strong><\/li>\n\n\n\n<li>Determines how to construct the subject name under which the key schema is registered with the Schema Registry for key. Here we use <strong>RecordNameStrategy <\/strong>to construct the subject name by namespace + record name. \n<ul class=\"wp-block-list\">\n<li>It means when publishing an Order message under <strong>com.thoainguyen.kafka.schema<\/strong> package, the subject name will be <strong>com.thoainguyen.kafka.schema.Order<\/strong> matched with our defined subjects.<\/li>\n\n\n\n<li>You can learn more about other strategies <a href=\"https:\/\/docs.confluent.io\/platform\/current\/schema-registry\/fundamentals\/serdes-develop\/index.html#sr-schemas-subject-name-strategy\">here<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Same as above but it is for value<\/li>\n\n\n\n<li>Define Schema Registry URL which is exposed from our Docker container in 3.1<\/li>\n\n\n\n<li>Tells Schema Registry that we will be using a specific Avro type (Order and OrderKey) otherwise Kafka will expect <strong>GenericRecord <\/strong>to be used on the topic<\/li>\n\n\n\n<li>Disable automatic schema registration, it is false by default which means client applications automatically register new schemas. \n<ul class=\"wp-block-list\">\n<li>If they produce new messages for a new topic, they will automatically try registering new schemas. This is convenient in development environments, but in production environments, it\u2019s recommended that client applications do not automatically register new schemas<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Tells binding to accept Avro content-type<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">All consumers and producers now need to use the Order POJO generated from Avro schema instead of defining them in our source code using <a href=\"https:\/\/github.com\/davidmc24\/gradle-avro-plugin?tab=readme-ov-file\">gradle-avro-plugin<\/a>. Additionally, the producers will need to wrap the customerId message key to the OrderKey object.<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-tangaroa-background-color has-text-color has-background\" style=\"padding-top:var(--wp--preset--spacing--40);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--40)\"><code>package com.thoainguyen.producer;\n\nimport com.thoainguyen.kafka.schema.Order;\nimport com.thoainguyen.kafka.schema.OrderKey;\nimport lombok.AllArgsConstructor;\nimport org.springframework.cloud.stream.function.StreamBridge;\nimport org.springframework.kafka.support.KafkaHeaders;\nimport org.springframework.messaging.Message;\nimport org.springframework.messaging.support.MessageBuilder;\nimport org.springframework.stereotype.Service;\n\n@Service\n@AllArgsConstructor\npublic class Producer {\n  private final StreamBridge streamBridge;\n\n  public void produceOrderCreated(Order order) {\n    OrderKey key = new OrderKey();\n    key.setCustomerId(order.getCustomerId());\n    Message&lt;Order> message = MessageBuilder.withPayload(order).setHeader(\n      KafkaHeaders.MESSAGE_KEY, key).build();\n    streamBridge.send(\"produceOrderCreated-out-0\",message);\n  }\n\n  public void produceOrderProcessed(Order order) {\n    OrderKey key = new OrderKey();\n    key.setCustomerId(order.getCustomerId());\n    Message&lt;Order> message = MessageBuilder.withPayload(order).setHeader(\n      KafkaHeaders.MESSAGE_KEY, key).build();\n    streamBridge.send(\"produceOrderProcessed-out-0\",message);\n  }\n}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">3.4. Test<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let start the application and send a request to the create order REST API that we created in the previous article to trigger an Order process.<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-tangaroa-background-color has-text-color has-background\" style=\"padding-top:var(--wp--preset--spacing--40);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--40)\"><code>curl --location --request POST 'localhost:8082\/app\/order\/14?customerId=100'<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you open our applications&#8217;s logs you will notice each message in the subscribed topic partitions is consumed by only one consumer successfully as the previous article which does not use Schema Registry.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But if we look at the Kafka UI, we can see the message key and value as a plain text because they were encoded into binary by the Scheme Registry.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"364\" src=\"https:\/\/thoaicoder.com\/wp-content\/uploads\/2024\/05\/anh-9-1024x364.png\" alt=\"\" class=\"wp-image-1076\" srcset=\"https:\/\/thoaicoder.com\/wp-content\/uploads\/2024\/05\/anh-9-1024x364.png 1024w, https:\/\/thoaicoder.com\/wp-content\/uploads\/2024\/05\/anh-9-300x107.png 300w, https:\/\/thoaicoder.com\/wp-content\/uploads\/2024\/05\/anh-9-768x273.png 768w, https:\/\/thoaicoder.com\/wp-content\/uploads\/2024\/05\/anh-9.png 1307w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\">4. Conclusion<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">The Schema Registry is vital for managing and validating data schemas in modern data architectures, especially with platforms like Apache Kafka. It ensures schema compatibility and consistency, enhancing data quality and governance. By enabling schema evolution, centralized management, and interoperability, it simplifies development and integration across systems. Incorporating a Schema Registry improves the reliability, maintainability, and scalability of data pipelines, making it indispensable for handling complex data ecosystems effectively. The source code of this demo project can be found on\u00a0<a href=\"https:\/\/github.com\/ThoaiNguyenHuu842\/spring-kafka-schema-registry\">GitHub<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Introduction In the previous article Kafka (Part 1) \u2013 Introduction we have walked through [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":950,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,6],"tags":[58,57,22],"class_list":["post-1022","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-big-data","category-ci-cd","tag-distributed-systems","tag-kafka","tag-micro-services"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.14 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Kafka (Part 2) - Schema Registry - I \u2764 Code<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/thoaicoder.com\/index.php\/2024\/05\/17\/kafka-part-2-schema-registry\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Kafka (Part 2) - Schema Registry - I \u2764 Code\" \/>\n<meta property=\"og:description\" content=\"1. Introduction In the previous article Kafka (Part 1) \u2013 Introduction we have walked through [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/thoaicoder.com\/index.php\/2024\/05\/17\/kafka-part-2-schema-registry\/\" \/>\n<meta property=\"og:site_name\" content=\"I \u2764 Code\" \/>\n<meta property=\"article:published_time\" content=\"2024-05-17T04:10:12+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-07-22T18:31:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/thoaicoder.com\/wp-content\/uploads\/2024\/04\/2024-04-16-23_14_19-Settings-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"998\" \/>\n\t<meta property=\"og:image:height\" content=\"450\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Thoai\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Thoai\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/thoaicoder.com\/index.php\/2024\/05\/17\/kafka-part-2-schema-registry\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/thoaicoder.com\/index.php\/2024\/05\/17\/kafka-part-2-schema-registry\/\"},\"author\":{\"name\":\"Thoai\",\"@id\":\"https:\/\/thoaicoder.com\/#\/schema\/person\/a3304c209434f63c501b05622d7d2720\"},\"headline\":\"Kafka (Part 2) &#8211; Schema Registry\",\"datePublished\":\"2024-05-17T04:10:12+00:00\",\"dateModified\":\"2024-07-22T18:31:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/thoaicoder.com\/index.php\/2024\/05\/17\/kafka-part-2-schema-registry\/\"},\"wordCount\":1095,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/thoaicoder.com\/#\/schema\/person\/a3304c209434f63c501b05622d7d2720\"},\"keywords\":[\"Distributed systems\",\"Kafka\",\"Micro-services\"],\"articleSection\":[\"Big data\",\"CI\/CD\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/thoaicoder.com\/index.php\/2024\/05\/17\/kafka-part-2-schema-registry\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/thoaicoder.com\/index.php\/2024\/05\/17\/kafka-part-2-schema-registry\/\",\"url\":\"https:\/\/thoaicoder.com\/index.php\/2024\/05\/17\/kafka-part-2-schema-registry\/\",\"name\":\"Kafka (Part 2) - Schema Registry - I \u2764 Code\",\"isPartOf\":{\"@id\":\"https:\/\/thoaicoder.com\/#website\"},\"datePublished\":\"2024-05-17T04:10:12+00:00\",\"dateModified\":\"2024-07-22T18:31:30+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/thoaicoder.com\/index.php\/2024\/05\/17\/kafka-part-2-schema-registry\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/thoaicoder.com\/index.php\/2024\/05\/17\/kafka-part-2-schema-registry\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/thoaicoder.com\/index.php\/2024\/05\/17\/kafka-part-2-schema-registry\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/thoaicoder.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Kafka (Part 2) &#8211; Schema Registry\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/thoaicoder.com\/#website\",\"url\":\"https:\/\/thoaicoder.com\/\",\"name\":\"I \u2764 Code\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/thoaicoder.com\/#\/schema\/person\/a3304c209434f63c501b05622d7d2720\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/thoaicoder.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/thoaicoder.com\/#\/schema\/person\/a3304c209434f63c501b05622d7d2720\",\"name\":\"Thoai\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/thoaicoder.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/thoaicoder.com\/wp-content\/uploads\/2023\/03\/photo_2023-01-05_22-53-32.jpg\",\"contentUrl\":\"https:\/\/thoaicoder.com\/wp-content\/uploads\/2023\/03\/photo_2023-01-05_22-53-32.jpg\",\"width\":640,\"height\":640,\"caption\":\"Thoai\"},\"logo\":{\"@id\":\"https:\/\/thoaicoder.com\/#\/schema\/person\/image\/\"},\"sameAs\":[\"https:\/\/thoaicoder.com\",\"https:\/\/www.linkedin.com\/in\/huu-thoai-nguyen\/\"],\"url\":\"https:\/\/thoaicoder.com\/index.php\/author\/admin_cvyxq4b8\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Kafka (Part 2) - Schema Registry - I \u2764 Code","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/thoaicoder.com\/index.php\/2024\/05\/17\/kafka-part-2-schema-registry\/","og_locale":"en_US","og_type":"article","og_title":"Kafka (Part 2) - Schema Registry - I \u2764 Code","og_description":"1. Introduction In the previous article Kafka (Part 1) \u2013 Introduction we have walked through [&hellip;]","og_url":"https:\/\/thoaicoder.com\/index.php\/2024\/05\/17\/kafka-part-2-schema-registry\/","og_site_name":"I \u2764 Code","article_published_time":"2024-05-17T04:10:12+00:00","article_modified_time":"2024-07-22T18:31:30+00:00","og_image":[{"width":998,"height":450,"url":"https:\/\/thoaicoder.com\/wp-content\/uploads\/2024\/04\/2024-04-16-23_14_19-Settings-1.png","type":"image\/png"}],"author":"Thoai","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Thoai","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/thoaicoder.com\/index.php\/2024\/05\/17\/kafka-part-2-schema-registry\/#article","isPartOf":{"@id":"https:\/\/thoaicoder.com\/index.php\/2024\/05\/17\/kafka-part-2-schema-registry\/"},"author":{"name":"Thoai","@id":"https:\/\/thoaicoder.com\/#\/schema\/person\/a3304c209434f63c501b05622d7d2720"},"headline":"Kafka (Part 2) &#8211; Schema Registry","datePublished":"2024-05-17T04:10:12+00:00","dateModified":"2024-07-22T18:31:30+00:00","mainEntityOfPage":{"@id":"https:\/\/thoaicoder.com\/index.php\/2024\/05\/17\/kafka-part-2-schema-registry\/"},"wordCount":1095,"commentCount":0,"publisher":{"@id":"https:\/\/thoaicoder.com\/#\/schema\/person\/a3304c209434f63c501b05622d7d2720"},"keywords":["Distributed systems","Kafka","Micro-services"],"articleSection":["Big data","CI\/CD"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/thoaicoder.com\/index.php\/2024\/05\/17\/kafka-part-2-schema-registry\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/thoaicoder.com\/index.php\/2024\/05\/17\/kafka-part-2-schema-registry\/","url":"https:\/\/thoaicoder.com\/index.php\/2024\/05\/17\/kafka-part-2-schema-registry\/","name":"Kafka (Part 2) - Schema Registry - I \u2764 Code","isPartOf":{"@id":"https:\/\/thoaicoder.com\/#website"},"datePublished":"2024-05-17T04:10:12+00:00","dateModified":"2024-07-22T18:31:30+00:00","breadcrumb":{"@id":"https:\/\/thoaicoder.com\/index.php\/2024\/05\/17\/kafka-part-2-schema-registry\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/thoaicoder.com\/index.php\/2024\/05\/17\/kafka-part-2-schema-registry\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/thoaicoder.com\/index.php\/2024\/05\/17\/kafka-part-2-schema-registry\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/thoaicoder.com\/"},{"@type":"ListItem","position":2,"name":"Kafka (Part 2) &#8211; Schema Registry"}]},{"@type":"WebSite","@id":"https:\/\/thoaicoder.com\/#website","url":"https:\/\/thoaicoder.com\/","name":"I \u2764 Code","description":"","publisher":{"@id":"https:\/\/thoaicoder.com\/#\/schema\/person\/a3304c209434f63c501b05622d7d2720"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/thoaicoder.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/thoaicoder.com\/#\/schema\/person\/a3304c209434f63c501b05622d7d2720","name":"Thoai","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/thoaicoder.com\/#\/schema\/person\/image\/","url":"https:\/\/thoaicoder.com\/wp-content\/uploads\/2023\/03\/photo_2023-01-05_22-53-32.jpg","contentUrl":"https:\/\/thoaicoder.com\/wp-content\/uploads\/2023\/03\/photo_2023-01-05_22-53-32.jpg","width":640,"height":640,"caption":"Thoai"},"logo":{"@id":"https:\/\/thoaicoder.com\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/thoaicoder.com","https:\/\/www.linkedin.com\/in\/huu-thoai-nguyen\/"],"url":"https:\/\/thoaicoder.com\/index.php\/author\/admin_cvyxq4b8\/"}]}},"_links":{"self":[{"href":"https:\/\/thoaicoder.com\/index.php\/wp-json\/wp\/v2\/posts\/1022","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thoaicoder.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thoaicoder.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thoaicoder.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thoaicoder.com\/index.php\/wp-json\/wp\/v2\/comments?post=1022"}],"version-history":[{"count":33,"href":"https:\/\/thoaicoder.com\/index.php\/wp-json\/wp\/v2\/posts\/1022\/revisions"}],"predecessor-version":[{"id":1079,"href":"https:\/\/thoaicoder.com\/index.php\/wp-json\/wp\/v2\/posts\/1022\/revisions\/1079"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/thoaicoder.com\/index.php\/wp-json\/wp\/v2\/media\/950"}],"wp:attachment":[{"href":"https:\/\/thoaicoder.com\/index.php\/wp-json\/wp\/v2\/media?parent=1022"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thoaicoder.com\/index.php\/wp-json\/wp\/v2\/categories?post=1022"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thoaicoder.com\/index.php\/wp-json\/wp\/v2\/tags?post=1022"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}