简体   繁体   English

Spring Kafka + Json + Schema Registry Confluent

[英]Spring Kafka + Json + Schema Registry Confluent

Confluent schema registry currently support json schema. Confluent 模式注册表当前支持 json 模式。 Does spring kafka provides support for json schema? spring kafka 是否提供对 json 架构的支持?

Avro with spring kafka works well using this config带有 spring kafka 的 Avro 使用此配置运行良好

spring:
  kafka:
    producer:
      key-serializer: org.apache.kafka.common.serialization.StringSerializer
      value-serializer: io.confluent.kafka.serializers.KafkaAvroSerializer
    consumer:
      group-id: template-cg
      auto-offset-reset: earliest
      key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
      value-deserializer: io.confluent.kafka.serializers.KafkaAvroDeserializer
    properties:
      schema.registry.url: "http://localhost:8081"

But how to configure spring kafka to use json schema + confluent schema registry?但是如何配置 spring kafka 以使用 json 模式 + 融合模式注册表?

OK, as gary guides, this is not spring problem.好的,作为加里指南,这不是 spring 问题。 Need to configure kafka like this.需要像这样配置kafka。

spring:
  kafka:
    producer:
      key-serializer: org.apache.kafka.common.serialization.StringSerializer
      value-serializer: io.confluent.kafka.serializers.json.KafkaJsonSchemaSerializer
    consumer:
      group-id: template-cg
      auto-offset-reset: earliest
      key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
      value-deserializer: io.confluent.kafka.serializers.json.KafkaJsonSchemaDeserializer
    properties:
      schema.registry.url: http://localhost:8081

Dependency (gradle)依赖(gradle)

repositories {
    mavenCentral()
    maven { 
        url "https://packages.confluent.io/maven/"
    }
    maven { 
        url "https://jitpack.io"
    }
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter'
    implementation 'org.springframework.kafka:spring-kafka'
    
    implementation 'io.confluent:kafka-json-schema-serializer:6.1.0'
    implementation 'com.github.everit-org.json-schema:org.everit.json.schema:1.12.2'
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 带有融合架构注册表的Spring Cloud Stream Kafka无法将消息发送到通道输出 - Spring Cloud Stream Kafka with confluent schema registry failed to send Message to channel output Spring-cloud kafka stream 模式注册表 - Spring-cloud kafka stream schema registry Spring Kafka 与 Confluent Kafka Avro 反序列化器 - Spring Kafka with Confluent Kafka Avro Deserializer spring-kafka 2.8.x 缺少必需的配置“schema.registry.url” - Missing required configuration "schema.registry.url" with spring-kafka 2.8.x Spring Kafka Test with Confluent Kafka Avro Serializer 找不到 ZKClientConfig - Spring Kafka Test with Confluent Kafka Avro Serializer cannot find ZKClientConfig 用于模式注册表和代理的 Kafka 客户端消费者配置 - Kafka Client Consumer Config for Schema Registry and Broker 使用 spring 引导在模式注册表中注册模式 - Registering a schema in schema registry using spring boot 如何禁用/启用 - 使用 Spring 引导配置文件的 Confluent KAFKA 拦截器? - How to disable/enable - Confluent KAFKA Interceptor using Spring boot profile? 无法将 spring 引导生产者应用程序连接到 kafka 融合主题 - Unable to connect spring boot producer app to kafka confluent topic 使用 Avro Schema 注册表的 Kafka 消费者单元测试失败 - Kafka consumer unit test with Avro Schema registry failing
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM