使用kafka-avro-console-producer,已经在模式注册表中存在的模式。

huangapple go评论65阅读模式
英文:

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 &lt;broker-list&gt; \
 --topic &lt;topic&gt;  \
 --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 &lt;broker-list&gt; \
 --topic &lt;topic&gt;  \
 --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=&quot;$(curl http://localhost:8081/schemas/ids/419 | jq -r .schema)&quot;

答案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 &lt;broker-list&gt; \
 --topic &lt;topic&gt;  \
 --property schema.registry.url=http://localhost:8081 \
 --property value.schema.id=419

huangapple
  • 本文由 发表于 2020年1月4日 00:45:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/59582230.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定