我正在尝试从模式注册表中检索给定 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 请求,或者更好的是,我应该如何使用架构注册表客户端
来检索架构?
最佳答案
使用以下方法解决了这个问题:
SchemaMetadata sm = client.getLatestSchemaMetadata(schemaName);
System.out.println(sm.getSchema());
关于java - 从 Confluence Schema 注册表中检索 Schema,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61109427/