Получить схему из реестра Confluent Schema - PullRequest
0 голосов
/ 08 апреля 2020

Я пытаюсь получить версии темы схемы, заданные kafka topi c из реестра схемы. Я могу успешно ПОСТАВИТЬ новую версию с 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 получить схему?

1 Ответ

0 голосов
/ 08 апреля 2020

Разобрался, используя:

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