Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void registerSchema(String topic,String schemaPath, String schemaUrl) throws IOException, RestClientException {
- // subject convention is "<topic-name>-value"
- String subject = topic + "-value";
- String schema;
- FileInputStream inputStream = new FileInputStream(schemaPath);
- try {
- schema = IOUtils.toString(inputStream);
- } finally {
- inputStream.close();
- }
- Schema avroSchema = new Schema.Parser().parse(schema);
- CachedSchemaRegistryClient client = new CachedSchemaRegistryClient(schemaUrl, 20);
- client.register(subject, avroSchema);
- }
Add Comment
Please, Sign In to add comment