如何使用 Avro Schema 配置 kafka 连接?

问题描述 投票:0回答:1

我已经开始学习Avro了。我想在kafka connect中实现它。我使用如下配置。这是正确的配置吗?

{
    "name": "surveyWawancara-connector",
    "config": {
        "connector.class": "io.debezium.connector.sqlserver.SqlServerConnector",
        "key.deserializer": "org.apache.kafka.connect.json.JsonDeserializer",
        "database.user": "Acquisition.ro",
        "database.dbname": "acquisition",
        "value.deserializer": "org.apache.kafka.connect.json.JsonDeserializer",
        "tasks.max": "1",
        "key.converter": "io.confluent.connect.avro.AvroConverter",
        "key.converter.schema.registry.url": "http://localhost:8081",
        "value.converter": "io.confluent.connect.avro.AvroConverter",
        "value.converter.schema.registry.url": "http://localhost:8081",
        "database.history.kafka.bootstrap.servers": "beta-kafka-brokers.amq-streams-beta.svc:9092",
        "database.history.kafka.topic": "schema-changes.sl.surveyWawancara",
        "time.precision.mode": "connect",
        "database.server.name": "beta-sl-bn",
        "database.port": "1433",
        "table.whitelist": "dbo.SurveyWawancara",
        "key.converter.schemas.enable": "true",
        "database.hostname": "10.7.76.62",
        "database.password": "Acquisition_ro231!",
        "value.converter.schemas.enable": "true",
        "name": "surveyWawancara-connector",
        "value.converter": "org.apache.kafka.connect.json.JsonConverter",
        "key.converter": "org.apache.kafka.connect.json.JsonConverter"
    }
}
apache-kafka avro apache-kafka-connect confluent-schema-registry
1个回答
1
投票

您已经复制了转换器字段,但这些属性是正确的,是的

"key.converter": "io.confluent.connect.avro.AvroConverter",
"key.converter.schema.registry.url": "http://localhost:8081",
"value.converter": "io.confluent.connect.avro.AvroConverter",
"value.converter.schema.registry.url": "http://localhost:8081", 

Avro 始终有一个模式,因此这些

*.schemas.enable
什么都不做,可以删除。

同样,解串器类配置不适用于 Connect 并且包含在转换器配置中,因此也应该删除

值得一提的是,密钥格式不必(并且通常不)与值匹配

© www.soinside.com 2019 - 2024. All rights reserved.