使用数据生成的ksql-datagen实用工具反序列化异常

时间:2019-01-04 05:04:14

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

通过以下模式从ksql-datagen实用程序生成的示例流-

{
        "type": "record",
        "name": "users",
        **"namespace": "com.example",**
        "fields": [
        {
        "name": "registertime",
        "type": {
            "type":"long",
            "arg.properties":{
                "range":{"min":1487715775521,"max":1519273364600}
                }
        }
        },
        {
                "name": "userid",
                "type": {
            "type":"string",
            "arg.properties":{"regex":"User_[1-9][0-2]"}
        }
        },
        {
                "name": "regionid",
                "type": {
            "type":"string",
            "arg.properties":{"regex":"Region_[1-9]"}
        }
        },
        {
                "name": "gender",
                "type": {
            "type":"string",
            "arg.properties":{
            "options":["MALE","FEMALE","OTHER"]
            }
        }
        }
]}

在检查版本时,它仍然选择“ io.confluent.ksql.avro_schemas”架构-

curl "http://localhost:8081/subjects/test-user-value/versions/1"

{“ subject”:“ test-user-value”,“ version”:1,“ id”:4,“ schema”:“ {” type“:” record“,” name“:” KsqlDataSourceSchema“, “名称空间”:“ io.confluent.ksql.avro_schemas” ,“字段”:[{“名称”:“注册时间”,“类型”:[“空”,“长”],” default“:null},{” name“:” userid“,” type“:[” null“,” string“],” default“:null},{” name“:” regionid“,” type“:[ “ null”,“ string”],“ default”:null},{“ name”:“ gender”,“ type”:[“ null”,“ string”],“ default”:null}]}“}}} < / p>

尝试使用Kafka-streams API时出现以下错误-

  

线程异常   “ PageView-Users-Stream-Join-eg-1dc610a3-c9d9-4c1e-b5eb-910e4bc74826-StreamThread-1”   org.apache.kafka.streams.errors.StreamsException:反序列化   异常处理程序设置为在反序列化错误时失败。如果你   宁愿流媒体管道在   反序列化错误,请设置   default.deserialization.exception.handler适当。在   org.apache.kafka.streams.processor.internals.RecordDeserializer.deserialize(RecordDeserializer.java:80)   在   org.apache.kafka.streams.processor.internals.RecordQueue.maybeUpdateTimestamp(RecordQueue.java:160)   在   org.apache.kafka.streams.processor.internals.RecordQueue.addRawRecords(RecordQueue.java:101)   在   org.apache.kafka.streams.processor.internals.PartitionGroup.addRawRecords(PartitionGroup.java:124)   在   org.apache.kafka.streams.processor.internals.StreamTask.addRecords(StreamTask.java:711)   在   org.apache.kafka.streams.processor.internals.StreamThread.addRecordsToTasks(StreamThread.java:995)   在   org.apache.kafka.streams.processor.internals.StreamThread.runOnce(StreamThread.java:833)   在   org.apache.kafka.streams.processor.internals.StreamThread.runLoop(StreamThread.java:777)   在   org.apache.kafka.streams.processor.internals.StreamThread.run(StreamThread.java:747)   造成原因:org.apache.kafka.common.errors.SerializationException:   反序列化ID为4的Avro消息时出错,原因是:   org.apache.kafka.common.errors.SerializationException:找不到   在作者的架构中指定的 io.confluent.ksql.avro_schemas.KsqlDataSourceSchema类,同时为以下内容找到读者的架构   SpecificRecord。

1 个答案:

答案 0 :(得分:1)

https://github.com/confluentinc/schema-registry/issues/980回答

  

Datagen始终将名称空间定义为io.confluent.ksql.avro_schemas。参见confluentinc/ksql#1906

现在也有other ways可以将测试数据生成到Kafka中。