使用kafka-rest代理发布Avro序列化数据 [英] Posting avro serialised data using kafka-rest proxy
本文介绍了使用kafka-rest代理发布Avro序列化数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在kafka主题上发布一些数据,该数据的avro模式包含联合类型.我正在android上使用kafka-rest代理来生成消息.
I am trying to Post some data on a kafka topic for which the avro schema of the data contains union types.I am using kafka-rest proxy on android to produce messages.
鉴于数据包含联合类型;从pojo到json转换器似乎都不起作用.
Given that data contains union type;none of the pojo to json converters seem to work.
推荐答案
请分享您的帖子数据.
我通常这样做是为了通过REST向Kafka Avro生成数据.
I normally do this to produce data to Kafka Avro via REST.
1)如果您没有架构ID:
1) If you don't have the schema ID:
curl --request POST \
--url http://MYKAFKARESTAPI/topics/MYTOPICNAME \
--header 'accept: application/vnd.kafka.v2+json' \
--header 'content-type: application/vnd.kafka.avro.v2+json' \
--data '{
"value_schema": "{\"type\": \"record\", \"name\": \"User\", \"fields\": [{\"name\": \"name\", \"type\": \"string\"},{\"name\": \"age\", \"type\": \"int\"}]}",
"records": [
{
"value": {
"name": "Maria",
"age": 10
}
},
{
"value": {
"name": "Jorge",
"age": 11
}
}
]
}'
如果您已经具有架构ID:
If you already have the schema ID:
curl --request POST \
--url http://MYKAFKARESTAPI/topics/MYTOPICNAME \
--header 'accept: application/vnd.kafka.v2+json' \
--header 'content-type: application/vnd.kafka.avro.v2+json' \
--data '{
"value_schema_id": 24,
"records": [
{
"value": {
"name": "Maria",
"age": 10
}
},
{
"value": {
"name": "Jorge",
"age": 11
}
}
]
}'
这篇关于使用kafka-rest代理发布Avro序列化数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文