How to fetch Kafka source connector schema based on connector name

*爱你&永不变心* 提交于 2019-12-08 06:51:11

问题


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

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


回答1:


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.

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

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

From there, in KSQL you just use

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

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

You can read more about Converters and serialisers here.

Disclaimer: I work for Confluent, and wrote the referenced blog post.



来源:https://stackoverflow.com/questions/53425385/how-to-fetch-kafka-source-connector-schema-based-on-connector-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!