检索ID为1的Avro模式时出错,找不到主题。错误代码:40401 [英] Error retrieving Avro schema for id 1, Subject not found.; error code: 40401

查看:401
本文介绍了检索ID为1的Avro模式时出错,找不到主题。错误代码:40401的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Caused by: org.apache.kafka.common.errors.SerializationException: Error retrieving Avro schema for id 1
Caused by: io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException: Subject not found.; error code: 40401

融合版本4.1.0

我正在使用KTable消费几个主题(topic_1,topic_2)中的数据,将数据合并,然后使用KStream将数据推送到另一个主题(topic_out)中。 (Ktable.toStream())

I am consuming data from a couple of topics(topic_1, topic_2) using KTable, joining the data and then pushing the data onto another topic(topic_out) using KStream. (Ktable.toStream())

数据为avro格式

当我使用来检查架构时

curl -X GET http://localhost:8081/subjects/ 

我发现

topic_1-value
topic_1-key
topic_2-value
topic_2-key
topic_out-value

,但是没有带有topic_out-key的主题。为什么不创建它?

but there is no subject with topic_out-key. Why is it not created?

topic_out的输出:

output from topic_out:

kafka-avro-console-consumer --bootstrap-server localhost:9092 --from-beginning --property print.key=true --topic topic_out

"code1  "   {"code":{"string":"code1  "},"personid":{"string":"=NA="},"agentoffice":{"string":"lic1        "},"status":{"string":"a"},"sourcesystem":{"string":"ILS"},"lastupdate":{"long":1527240990138}}

我可以看到正在生成密钥,但是没有密钥的主题。

I can see the key being generated, but no subject for key.

为什么需要具有密钥的主题?

我正在将这个主题提供给另一个连接器(hdfs-sink)以将数据推送到hdfs,但失败并出现以下错误

Why is subject with key required?
I am feeding this topic to another connector (hdfs-sink) to push the data to hdfs but it fails with below error

Caused by: org.apache.kafka.common.errors.SerializationException: Error retrieving Avro schema for id 5\nCaused by: io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException: Subject not found.; error code: 40401

当我查看schema-registry.logs时,可以看到:

when I look at the schema-registry.logs, I can see:

[2018-05-24 15:40:06,230] INFO 127.0.0.1 - - 
[24/May/2018:15:40:06 +0530] "POST /subjects/topic_out-key?deleted=true HTTP/1.1" 404 51  9 (io.confluent.rest-utils.requests:77)

为什么不创建主题topic_out-key?

any idea why the subject topic_out-key not being created?

推荐答案


不知道为何未创建主题topic_out-key

any idea why the subject topic_out-key not being created

Kafka Streams输出的键是一个字符串,而不是Avro编码的字符串。

Because the Key of your Kafka Streams output is a String, not an Avro encoded string.

您可以使用 kafka-console-consumer 并添加-property来验证print.value = false 并在打印值时没有看到与同一命令相比的任何特殊字符(这表明数据是二进制Avro)

You can verify that using kafka-console-consumer instead and adding --property print.value=false and not seeing any special characters compared to the same command when you do print the value (this is showing the data is binary Avro)

在Kafka Connect中,必须将Kafka的StringConverter类用于 key.converter 属性,而不是Confluent Avro一个

From Kafka Connect, you must use Kafka's StringConverter class for key.converter property rather than the Confluent Avro one

这篇关于检索ID为1的Avro模式时出错,找不到主题。错误代码:40401的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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