配置Kafka Streams应用程序以使用Confluent Schema Registry

时间:2019-12-10 11:26:34

标签: java apache-kafka apache-kafka-streams confluent confluent-schema-registry

我有一个Kafka Streams Java应用程序,该应用程序处理Avro Kafka Topic,对数据进行一些更改,并将处理后的结果在Avro中存储到另一个Topic中。

为此,我正在使用Avro GenericRecord Serde,因此我可以反序列化每个记录,修改所需的字段,然后再次将其序列化到Avro。

这是Serde声明,配置为使用架构注册表 http://localhost:8082

Map<String, String> serdeConfig;
serdeConfig = Collections.singletonMap("schema.registry.url","http://localhost:8082");
Serde<GenericRecord> keyGenericAvroSerde = new GenericAvroSerde();
Serde<GenericRecord> valueGenericAvroSerde = new GenericAvroSerde();
keyGenericAvroSerde.configure(serdeConfig, true);
valueGenericAvroSerde.configure(serdeConfig, false);

使用配置好的serde将结果存入目标主题:

//Process Stream
ObfuscateTopicProcessor obfuscateTopicProcessor = new ObfuscateTopicProcessor(environment, appName);
StreamsBuilder builder = new StreamsBuilder();
obfuscateTopicProcessor.convert(builder, topics, fieldList)
        .to((k, v, r) -> r.topic() + topicSufix, Produced.with(keyGenericAvroSerde, valueGenericAvroSerde));
//Run Stream
Topology topology = builder.build();
KafkaStreams streams = new KafkaStreams(topology, props);

问题:当我运行该应用程序时,它运行良好,但是它在Schema-Registry http://localhost:8081 中生成了新的已处理主题架构。 < / p>

这是应用程序的日志,它应该在http://localhost:8082中创建新的主题架构:

[2019-12-10 10:46:51,190] [INFO] KafkaAvroSerializerConfig values:
    bearer.auth.token = [hidden]
    schema.registry.url = [http://localhost:8082]
    basic.auth.user.info = [hidden]
    auto.register.schemas = true
    max.schemas.per.subject = 1000
    basic.auth.credentials.source = URL
    schema.registry.basic.auth.user.info = [hidden]
    bearer.auth.credentials.source = STATIC_TOKEN
    value.subject.name.strategy = class io.confluent.kafka.serializers.subject.TopicNameStrategy
    key.subject.name.strategy = class io.confluent.kafka.serializers.subject.TopicNameStrategy  (io.confluent.kafka.serializers.KafkaAvroSerializerConfig)

我缺少任何重要的配置参数吗?

0 个答案:

没有答案