in example/src/main/java/org/apache/rocketmq/schema/registry/example/RegisterSchemaDemo.java [32:54]
public static void main(String[] args) {
String baseUrl = "http://localhost:8080";
SchemaRegistryClient schemaRegistryClient = SchemaRegistryClientFactory.newClient(baseUrl, null);
String topic = "TopicTest";
RegisterSchemaRequest request = RegisterSchemaRequest.builder()
.schemaIdl("{\"type\":\"record\",\"name\":\"Charge\",\"namespace\":\"org.apache.rocketmq.schema.registry.example.serde\","
+ "\"fields\":[{\"name\":\"item\",\"type\":\"string\"},{\"name\":\"amount\",\"type\":\"double\"}]}")
.schemaType(SchemaType.AVRO)
.compatibility(Compatibility.BACKWARD)
.owner("test").build();
try {
RegisterSchemaResponse response
= schemaRegistryClient.registerSchema(topic, "Charge", request);
System.out.println("register schema success, schemaId: " + response.getRecordId());
Thread.sleep(5000);
System.out.println("current schema: " + schemaRegistryClient.getSchemaBySubject(topic));
} catch (RestClientException | IOException | InterruptedException e) {
e.printStackTrace();
}
}