英文:
Is there a need of seperate Key Schema(other than a schema for fields) while writing Avro producer?
问题
我正在为我的项目编写Java Avro生产者代码。我已经为所有需要传递的字段注册了Avro模式。
我的已注册模式-
{
"name": "Claim",
"type": "record",
"namespace": "com.schema.avro",
"fields": [
{
"name": "icn",
"type": "string"
},
{
"name": "fln,
"type": "int"
},
]
}
我正在使用"icn"字段值作为键,但我没有单独注册键模式。我不确定是否需要。
i) 我可以直接使用已在当前模式中的字段("icn"在这种情况下)作为键,而无需注册键模式吗?
ii) 我需要单独注册键模式吗?如果是这样,那么它是否是已为字段创建的模式的一部分,还是与之不同?
英文:
I am writing Java Avro Producer code for my project. I have registered an Avro schema for all the fields which need to be passed.
My Registered Schema-
{
"name": "Claim",
"type": "record",
"namespace": "com.schema.avro",
"fields": [
{
"name": "icn",
"type": "string"
},
{
"name": "fln,
"type": "int"
},
]
}
I am using "icn" field value as a key but I don't have a key schema registered separately. I am not sure if that is required.
i) Can I directly use a field already in my current schema("icn" in this case) as the key without having to register a key schema?
ii) Do I need to register the key schema separately? If so, is that part of the schema already created for fields or is it different?
答案1
得分: 1
你无需为键使用 Avro。如果您的键是字符串类型,可以使用 org.apache.kafka.common.serialization.StringSerializer。如果您想使用 Avro,您需要为每种对象类型注册模式。
英文:
You are not required to use avro for keys. If your key is of type string you may use org.apache.kafka.common.serialization.StringSerializer. If you want to use avro, you need to register the schema for each object type.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论