【问题标题】:Retrieve Schema From Confluent Schema Registry从 Confluent Schema Registry 中检索 Schema
【发布时间】:2020-04-08 20:25:53
【问题描述】:

我正在尝试从架构注册表中检索给定 kafka 主题的架构主题版本。我可以使用client.register(schema-name, schema) 成功发布新版本,但我不确定如何检索这些版本。我在下面尝试使用 curl 请求,但结果立即命中 -1(空)。

CachedSchemaRegistryClient client = new CachedSchemaRegistryClient(schemaRegistryUrl, 20);

// curl -X GET http://schema.registry.url:8888/subjects/{topic}/versions/

String command = "curl -X GET --header 'Accept: application/vnd.schemaregistry.v1+json' 'https://schema.registry.url:8888/api/schema-proxy/subjects/mytopic-value/versions'";
Process process = Runtime.getRuntime().exec(command);

Reader reader = new InputStreamReader(process.getInputStream());
int result;
while ((result = reader.read()) != -1){ // Nothing printed
    System.out.println(result);
}

我该如何解决这个 GET 请求,或者更好的是,我应该如何使用架构注册表 client 来检索架构?

【问题讨论】:

    标签: java apache-kafka confluent-schema-registry


    【解决方案1】:

    想通了:

    SchemaMetadata sm = client.getLatestSchemaMetadata(schemaName);
    System.out.println(sm.getSchema());
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-04
      • 2023-01-11
      • 2019-05-01
      • 2017-10-06
      • 2022-12-24
      • 2019-07-21
      • 2019-07-21
      • 2018-03-27
      相关资源
      最近更新 更多