apache-kafka - Confluent Schema Registry 超时错误
问题描述
我正在使用 Avro 模式将数据写入 Kafka 主题。最初,一切正常。在 avro 文件中添加一个新字段(scan_app_id)后。我正面临这个错误。
Avro 文件:{
“type”:“record”,“name”:“Initiate_Scan”,“namespace”:“avro”,“doc”:“Initiate_Scan 的 Avro 模式注册表”,“fields”:[ { “name”:“app_id”, "type": "string", "doc": "3 digit application id" },
{ "name": "app_name", "type": "string", "doc": "application name" }, { "name": "dev_stage", "type": "string", "doc": "development stage" }, { "name": "scan_app_id", "type": "string", "doc": "unique scan id for an app in Veracode" }, { "name": "scan_name", "type": "string", "doc": "scan details" }, { "name": "seq_num", "type": "int", "doc": "unique number" }, { "name": "result_flg", "type": "string", "doc": "Y indicates results of scan available", "default": "Y" }, { "name": "request_id", "type": "int", "doc": "unique id" }, { "name": "scan_number", "type": "int", "doc": "number of scans" } ] }
错误:由以下原因引起:org.apache.kafka.common.errors.SerializationException:注册 Avro 架构时出错:{"type":"record","name":"Initiate_Scan","namespace":"avro","doc" :"Initiate_Scan 的 Avro 模式注册表","fields":[{"name":"app_id","type":{"type":"string","avro.java.string":"String"}," doc":"3 位应用程序 ID"},{"name":"app_name","type":{"type":"string","avro.java.string":"String"},"doc": "应用程序名称"},{"name":"dev_stage","type":{"type":"string","avro.java.string":"String"},"doc":"开发阶段"}, {"name":"scan_app_id","type":{"type":"string","avro.java.string":"String"},"doc":"应用程序的唯一扫描 ID"},{"name":"scan_name","type":{"type":"string","avro.java.string":"String"},"doc":"scan details"},{"name": "seq_num","type":"int","doc":"唯一编号"},{"name":"result_flg","type":{"type":"string","avro.java.string ":"String"},"doc":"Y 表示扫描结果可用","default":"Y"},{"name":"request_id","type":"int","doc": "唯一 id"},{"name":"scan_number","type":"int","doc":"扫描次数"}]}
INFO 使用 timeoutMillis = 9223372036854775807 毫秒关闭 Kafka 生产者。(org.apache.kafka.clients.producer.KafkaProducer:1017) 引起:io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException:注册操作超时;错误代码:50002 在 io.confluent.kafka.schemaregistry.client.rest.RestService.sendHttpRequest(RestService.java:182) 在 io.confluent.kafka.schemaregistry.client.rest.RestService.httpRequest(RestService.java:203)在 io.confluent.kafka.schemaregistry.client.rest.RestService.registerSchema(RestService.java:292) 在 io.confluent.kafka.schemaregistry.client.rest.RestService.registerSchema(RestService.java:284) 在 io.confluent .kafka.schemaregistry.client.rest.RestService.registerSchema(RestService.java:279) 在 io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient。
我浏览了有关 50002 错误的Confluent 文档,其中说
模式应与先前注册的模式兼容。
这是否意味着我无法更改/更新现有架构?
如何解决这个问题?
解决方案
实际上,链接说50002 -- Operation timed out
。如果它确实不兼容,那么响应实际上会这样说。
在任何情况下,如果您添加一个新字段,您都需要定义一个default
值。
这样,任何使用更新模式定义且正在读取旧消息的消费者都知道要为该字段设置什么值。
我发现的允许 Avro 更改的简单列表是由 Oracle 提供的
可能的错误是:
- 添加的字段没有默认值
推荐阅读
- react-native - 在一个场景中渲染所有前端
- c++ - c++ 是否可以“通过引用传递”?
- python-2.7 - 如何使用树莓派和 smtplib 通过电子邮件发送变量值
- c++ - 指向内存分配的指针问题
- google-bigquery - 不包含特定单词的数据的大查询显示结果
- amazon-web-services - 如何从 boto3 的配置文件中检索 mfa_serial?
- vue.js - 通过邮递员成功上传文件但在前端失败(vue)
- wpf - 如何将枚举与 IValueConverter 绑定?
- mysql - 在 jdbc 连接器中使用递增摄取的问题
- java - 查找用于交织字符串的递归算法的计算复杂度