融合架构注册表超时错误

时间:2019-04-18 11:35:11

标签: apache-kafka avro confluent confluent-schema-registry

我正在使用Avro模式将数据写入Kafka主题。最初,一切正常。在avro文件中添加另一个新字段(scan_app_id)之后。我正遇到此错误。

  

Avro文件:   {

     

“类型”:“记录”,“名称”:“ Initiate_Scan”,“名称空间”:“ avro”,   “ doc”:“ Initiate_Scan的Avro模式注册表”,“ fields”:[       {         “ name”:“ app_id”,         “ type”:“ string”,         “ doc”:“ 3位数字的应用程序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模式时出错:   {“类型”:“记录”,“名称”:“ Initiate_Scan”,“名称空间”:“ avro”,“ doc”:“ Avro   的架构注册表   Initiate_Scan“,” 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“},{” name“:” dev_stage“,” type“:{” type“:” string“,” avro.java.string“:” String“},” doc“:”开发   stage“}, {” name“:” scan_app_id“,” type“:{” type“:” string“,” avro.java.string“:” String“},” doc“:” unique   扫描ID   App“} ,{” name“:” scan_name“,” type“:{” type“:” string“,” avro.java.string“:” String“},” doc“:” scan   details“},{” name“:” seq_num“,” type“:” int“,” doc“:”唯一   number“},{” name“:” result_flg“,” type“:{” type“:” string“,” avro.java.string“:” String“},” doc“:” Y   指示扫描结果   可用“,”默认“:” Y“},{”名称“:” request_id“,”类型“:” int“,” doc“:”唯一   id“},{” name“:” scan_number“,” type“:” int“,” doc“:”扫描次数“}]}

INFO使用timeMills = 9223372036854775807 ms来关闭Kafka生产者。 (org.apache.kafka.clients.producer.KafkaProducer:1017) 由以下原因引起:io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException:注册操作超时;默认值为0。错误代码: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.registerAndGetId(CachedSchemaRegistryClient.java:61)     在io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient.register(CachedSchemaRegistryClient.java:93)     在io.confluent.kafka.serializers.AbstractKafkaAvroSerializer.serializeImpl(AbstractKafkaAvroSerializer.java:72)     在io.confluent.kafka.serializers.KafkaAvroSerializer.serialize(KafkaAvroSerializer.java:54)     在org.apache.kafka.common.serialization.ExtendedSerializer $ Wrapper.serialize(ExtendedSerializer.java:65)中     在org.apache.kafka.common.serialization.ExtendedSerializer $ Wrapper.serialize(ExtendedSerializer.java:55)     在org.apache.kafka.clients.producer.KafkaProducer.doSend(KafkaProducer.java:768)     在org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:745)     在com.ssc.svc.svds.initiate.InitiateProducer.initiateScanData(InitiateProducer.java:146)     在com.ssc.svc.svds.initiate.InitiateProducer.topicsData(InitiateProducer.java:41)     在com.ssc.svc.svds.initiate.InputData.main(InputData.java:31)

我经历了Confluent documentation大约50002错误,它说

  

模式应与先前注册的模式兼容。

这是否意味着我无法更改/更新现有架构?

该如何解决?

1 个答案:

答案 0 :(得分:0)

实际上,该链接显示为50002 -- Operation timed out。如果确实不兼容,那么响应实际上就是这样。

无论如何,如果添加新字段,则需要定义一个default值。

这样,任何使用较新架构定义的使用者都在读取较旧的消息,则知道要为该字段设置什么值。

A straight-forward list of allowed Avro changes I found is by Oracle

  

可能的错误是:

     
      
  • 添加了一个字段,没有默认值
  •