英文:
Use kafka-avro-console-producer with a schema already in the schema registry
问题
我想使用带有模式注册表的kafka-avro-console-producer
。我有大型模式(超过10k字符),不能将它们作为命令行参数粘贴。除此之外,我想直接使用模式注册表,以便可以使用特定的模式ID。
我在考虑这样的方法,但它不起作用:
kafka-avro-console-producer \
--broker-list <broker-list> \
--topic <topic> \
--property schema.registry.url=http://localhost:8081 \
--property value.schema=`curl http://localhost:8081/schemas/ids/419`
英文:
I would like to use the kafka-avro-console-producer
with the schema registry. I have big schemas (over 10k chars) and I can't really past them as a command line argument. Besides that I'd like to use the schema registry directly so I can use a specific schema id.
I'm thinking about something like this, but it doesn't work:
kafka-avro-console-producer \
--broker-list <broker-list> \
--topic <topic> \
--property schema.registry.url=http://localhost:8081 \
--property value.schema=`curl http://localhost:8081/schemas/ids/419`
答案1
得分: 22
## 对于当前版本的CLI工具
```shell
kafka-avro-console-producer \
--broker-list <broker-list> \
--topic <topic> \
--property schema.registry.url=http://localhost:8081 \
--property value.schema.id=419
对于旧版本
您需要使用jq从API请求中提取模式,例如
value.schema="$(curl http://localhost:8081/schemas/ids/419 | jq -r .schema)"
<details>
<summary>英文:</summary>
## For the current version of the CLI tool
```shell
kafka-avro-console-producer \
--broker-list <broker-list> \
--topic <topic> \
--property schema.registry.url=http://localhost:8081 \
--property value.schema.id=419
For older version
You'll need to extract the schema from the API request using jq, for example
value.schema="$(curl http://localhost:8081/schemas/ids/419 | jq -r .schema)"
答案2
得分: 8
你可以使用属性 value.schema.id
:
kafka-avro-console-producer \
--broker-list <broker-list> \
--topic <topic> \
--property schema.registry.url=http://localhost:8081 \
--property value.schema.id=419
英文:
You can use the property value.schema.id
:
kafka-avro-console-producer \
--broker-list <broker-list> \
--topic <topic> \
--property schema.registry.url=http://localhost:8081 \
--property value.schema.id=419
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论