如何根据连接器名称获取 Kafka 源连接器架构 [英] How to fetch Kafka source connector schema based on connector name

本文介绍了如何根据连接器名称获取 Kafka 源连接器架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Confluent JDBC Kafka 连接器将消息发布到主题中.源连接器将在每次轮询时将数据与模式一起发送到主题.我想检索这个模式.

I am using Confluent JDBC Kafka connector to publish messages into topic. The source connector will send data to topic along with schema on each poll. I want to retrieve this schema.

有可能吗?如何?谁能推荐我

Is it possible? How? Can anyone suggest me

我的目的是基于 Kafka 连接器在轮询时构建的架构创建 KSQL 流或表.

My intention is to create a KSQL stream or table based on schema build by Kafka connector on poll.

推荐答案

最好的方法是使用 Avro,其中架构单独存储,并由 Kafka Connect 和 KSQL 自动使用.

The best way to do this is to use Avro, in which the schema is stored separately and automatically used by Kafka Connect and KSQL.

您可以通过将 Kafka Connect 配置为使用 AvroConverter 来使用 Avro.在您的 Kafka Connect 工作器配置集中:

You can use Avro by configuring Kafka Connect to use the AvroConverter. In your Kafka Connect worker configuration set:

key.converter=io.confluent.connect.avro.AvroConverter
key.converter.schema.registry.url=http://schema-registry:8081

(schema-registry 更新为运行 Schema Registry 的主机名)

(Update schema-registry to the hostname of where your Schema Registry is running)

从那里开始,在 KSQL 中您只需使用

From there, in KSQL you just use

CREATE STREAM my_stream WITH (KAFKA_TOPIC='source_topic', VALUE_FORMAT='AVRO');

您无需在此处指定架构本身,因为 KSQL 会从架构注册表中获取它.

You don't need to specify the schema itself here, because KSQL fetches it from the Schema Registry.

您可以在此处阅读有关转换器和序列化程序的更多信息.

免责声明:我为 Confluent 工作,并撰写了引用的博客文章.

这篇关于如何根据连接器名称获取 Kafka 源连接器架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆