我正试图将此消息发布到Kafka Rest:
{
"key_schema": "[\"null\",\"long\"]",
"value_schema": "{\"type\":\"record\",\"name\":\"GVEDGE_FI_INVOICE_TX_INFO_V2\",\"namespace\":\"com.vistajet.gvedge.infrastructure.kafka.connector\",\"fields\":[{\"name\":\"XID\",\"type\":[\"null\",\"long\"],\"default\":null},{\"name\":\"ID\",\"type\":[\"null\",\"long\"],\"default\":null},{\"name\":\"INVOICE_CHANGE_COUNT\",\"type\":[\"null\",\"long\"],\"default\":null},{\"name\":\"INVOICE_DETAIL_CHANGE_COUNT\",\"type\":[\"null\",\"long\"],\"default\":null},{\"name\":\"ADDITIONAL_INVL_CHANGE_COUNT\",\"type\":[\"null\",\"long\"],\"default\":null},{\"name\":\"COST_ALLOCATION_CHANGE_COUNT\",\"type\":[\"null\",\"long\"],\"default\":null}],\"connect.name\":\"com.vistajet.gvedge.infrastructure.kafka.connector.GVEDGE_FI_INVOICE_TX_INFO_V2\"}",
"records": [
{
"key": {
"long": 140766
},
"value": {
"XID": {
"long": 29524623
},
"ID": {
"long": 140766
},
"INVOICE_CHANGE_COUNT": {
"long": 1
},
"INVOICE_DETAIL_CHANGE_COUNT": {
"long": 0
},
"ADDITIONAL_INVL_CHANGE_COUNT": {
"long": 0
},
"COST_ALLOCATION_CHANGE_COUNT": {
"long": 0
}
}
}
]
}
在rest-proxy.log中出现以下错误:
[2019-04-11 14:25:58,991]错误未处理的异常导致 内部服务器错误响应 (io.confluent.rest.exceptions.GenericExceptionMapper:38) org.apache.kafka.common.errors.SerializationException:错误 正在注册Avro模式:“长”的原因: io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException: 正在注册的架构与早期的架构不兼容;错误 代码:409
为什么会这样???我不明白为什么
"key": {
"long": 140766
}
正在触发新的架构创建吗?...
顺便说一句
"key": null
工作正常。
答案 0 :(得分:0)
您正在将键值设置为对象。
"key": {
"long": 140766
}
哪个不反映您的架构:
"key_schema": "[\"null\",\"long\"]",
尝试:
{
"key_schema": "{\"type\":\"long\"}",
"value_schema": "{\"type\":\"record\",\"name\":\"GVEDGE_FI_INVOICE_TX_INFO_V2\",\"namespace\":\"com.vistajet.gvedge.infrastructure.kafka.connector\",\"fields\":[{\"name\":\"XID\",\"type\":[\"null\",\"long\"],\"default\":null},{\"name\":\"ID\",\"type\":[\"null\",\"long\"],\"default\":null},{\"name\":\"INVOICE_CHANGE_COUNT\",\"type\":[\"null\",\"long\"],\"default\":null},{\"name\":\"INVOICE_DETAIL_CHANGE_COUNT\",\"type\":[\"null\",\"long\"],\"default\":null},{\"name\":\"ADDITIONAL_INVL_CHANGE_COUNT\",\"type\":[\"null\",\"long\"],\"default\":null},{\"name\":\"COST_ALLOCATION_CHANGE_COUNT\",\"type\":[\"null\",\"long\"],\"default\":null}],\"connect.name\":\"com.vistajet.gvedge.infrastructure.kafka.connector.GVEDGE_FI_INVOICE_TX_INFO_V2\"}",
"records": [
{
"key": 234,
"value": {
"XID": {
"long": 29524623
},
"ID": {
"long": 140766
},
"INVOICE_CHANGE_COUNT": {
"long": 1
},
"INVOICE_DETAIL_CHANGE_COUNT": {
"long": 0
},
"ADDITIONAL_INVL_CHANGE_COUNT": {
"long": 0
},
"COST_ALLOCATION_CHANGE_COUNT": {
"long": 0
}
}
}
]
}
现在您的密钥的类型为long。因此,您只能在输入数据的旁边输入数字。
但是,如果要像上面的示例一样将键值保留为对象,则还需要将键定义为记录类型:
{
"key_schema": "{\"type\":\"record\",\"name\":\"GVEDGE_FI_INVOICE_TX_INFO_V2_KEY\",\"namespace\":\"com.vistajet.gvedge.infrastructure.kafka.connector\",\"fields\":[{\"name\":\"long\",\"type\":[\"null\",\"long\"]}]}",
"value_schema": "{\"type\":\"record\",\"name\":\"GVEDGE_FI_INVOICE_TX_INFO_V2\",\"namespace\":\"com.vistajet.gvedge.infrastructure.kafka.connector\",\"fields\":[{\"name\":\"XID\",\"type\":[\"null\",\"long\"],\"default\":null},{\"name\":\"ID\",\"type\":[\"null\",\"long\"],\"default\":null},{\"name\":\"INVOICE_CHANGE_COUNT\",\"type\":[\"null\",\"long\"],\"default\":null},{\"name\":\"INVOICE_DETAIL_CHANGE_COUNT\",\"type\":[\"null\",\"long\"],\"default\":null},{\"name\":\"ADDITIONAL_INVL_CHANGE_COUNT\",\"type\":[\"null\",\"long\"],\"default\":null},{\"name\":\"COST_ALLOCATION_CHANGE_COUNT\",\"type\":[\"null\",\"long\"],\"default\":null}],\"connect.name\":\"com.vistajet.gvedge.infrastructure.kafka.connector.GVEDGE_FI_INVOICE_TX_INFO_V2\"}",
"records": [
{
"key": {
"long": {"long": 7}
},
"value": {
"XID": {
"long": 29524623
},
"ID": {
"long": 140766
},
"INVOICE_CHANGE_COUNT": {
"long": 1
},
"INVOICE_DETAIL_CHANGE_COUNT": {
"long": 0
},
"ADDITIONAL_INVL_CHANGE_COUNT": {
"long": 0
},
"COST_ALLOCATION_CHANGE_COUNT": {
"long": 0
}
}
}
]
}
现在回到您的主要问题:“正在注册的架构与早期的架构不兼容”。
该消息向自己说明您正在尝试更改架构。但是,您不能更改相同的名称,因为它与当前版本的架构不兼容。
如果确定仅用于开发,则可以将架构兼容性级别暂时更改为“ NONE”。
然后重试。
否则,请检查您在先前的密钥架构和新的密钥架构之间进行了哪些更改,以及为什么不兼容。