簡體   English   中英

無法連接到 KSql 中的外部主題

[英]Can't hook up to external topic in KSql

我對 Confluent KSql 很陌生,但對 Kafka 並不陌生。 我有存在於 Kafka 中的現有主題作為 Avro 序列化數據。 我已經啟動並運行了 Confluent 模式注冊表,並將 KSql 配置為指向注冊表。

當我嘗試根據我的主題之一創建表時,KSql 抱怨它找不到流。 當我嘗試在 KSql 中創建一個流,它只是在 KSql 中流式傳輸我的主題時,似乎無法指向我的 Avro 序列化主題,該主題在注冊表中有一個引用。

有誰知道如何解決這兩個問題? 我想使用 KSql 的方式不適合它可以做什么?

更新

這里有更多細節

ksql> show topics;

 Kafka Topic                                                                                 | Registered | Partitions | Partition Replicas | Consumers | Consumer Groups
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 COM_FINDOLOGY_MODEL_REPORTING_OUTGOINGFEEDADVERTISERSEARCHDATA                              | false      | 2          | 2                  | 0         | 0
 COM_FINDOLOGY_MODEL_TRAFFIC_CPATRACKINGCALLBACK                                             | false      | 2          | 2                  | 0         | 0
 COM_FINDOLOGY_MODEL_TRAFFIC_ENTRYPOINTCLICK                                                 | true       | 10         | 3                  | 0         | 0

KSql配置

#bootstrap.servers=localhost:9092
bootstrap.servers=host1:9092,host2:9092,host3:9092,host4:9092,host5:9092

#listeners=http://localhost:8088
listeners=http://localhost:59093

ksql.server.ui.enabled=true

ksql.schema.registry.url=http://host1:59092

注冊表配置

# The host name advertised in ZooKeeper. Make sure to set this if running Schema Registry with multiple nodes.
host.name: x.x.x.x
listeners=http://0.0.0.0:59092

# Zookeeper connection string for the Zookeeper cluster used by your Kafka cluster
# (see zookeeper docs for details).
# This is a comma separated host:port pairs, each corresponding to a zk
# server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002".
#kafkastore.connection.url=localhost:2181

# Alternatively, Schema Registry can now operate without Zookeeper, handling all coordination via
# Kafka brokers. Use this setting to specify the bootstrap servers for your Kafka cluster and it
# will be used both for selecting the master schema registry instance and for storing the data for
# registered schemas.
# (Note that you cannot mix the two modes; use this mode only on new deployments or by shutting down
# all instances, switching to the new configuration, and then starting the schema registry
# instances again.)
kafkastore.bootstrap.servers=PLAINTEXT://host1:9092,PLAINTEXT://host2:9092,PLAINTEXT://host3:9092,PLAINTEXT://host4:9092,PLAINTEXT://host5:9092

# The name of the topic to store schemas in
kafkastore.topic=_schemas

# If true, API requests that fail will include extra debugging information, including stack traces
debug=false

試圖通過聲明一個外部主題來解決問題

ksql> register  topic xxx with (value_format='avro', kafka_topic='COM_FINDOLOGY_MODEL_REPORTING_OUTGOINGFEEDADVERTISERSEARCHDATA');
You need to provide avro schema file path for topics in avro format.

REGISTER TOPIC是不推薦使用的語法。 您應該使用CREATE STREAM (或CREATE TABLE ,具體取決於您的數據訪問要求)。

所以你的陳述看起來像這樣:

CREATE STREAM MY_STREAM_1 \
  WITH (VALUE_FORMAT='AVRO', \
  KAFKA_TOPIC='COM_FINDOLOGY_MODEL_REPORTING_OUTGOINGFEEDADVERTISERSEARCHDATA');

請注意,為了便於閱讀,我使用\\來斷行; 你不必這樣做。

我解決了在更改我從 Kafka 主題中使用的信息后遇到的問題,而不是使用整個主題內容。 該主題包含使用ReflectionData創建的 Avro 編碼數據(ok)。 KSql在處理流中的非標准項時有問題,但只要有對應的 KSql 數據類型,它就會處理 ReflectionData 項。 我通過在 KSql 中創建一個新流來解決這個問題,該流只選擇了我需要的也與 KSql 兼容的項目。 完成后,我可以從更大的流中處理我需要的內容。

評論我認為 KSql 的一個缺陷是你必須在Kafka創建新的實際中間主題來處理數據。 我認為更好的解決方案是將中間流視為實際流中的View 我理解,在將其解析為 KTable 之前,需要中間主題來保存累積和處理的項目。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM