Guest User

Untitled

a guest
Nov 20th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. public static void registerSchema(String topic,String schemaPath, String schemaUrl) throws IOException, RestClientException {
  2.  
  3. // subject convention is "<topic-name>-value"
  4. String subject = topic + "-value";
  5.  
  6. String schema;
  7.  
  8. FileInputStream inputStream = new FileInputStream(schemaPath);
  9. try {
  10. schema = IOUtils.toString(inputStream);
  11. } finally {
  12. inputStream.close();
  13. }
  14.  
  15. Schema avroSchema = new Schema.Parser().parse(schema);
  16.  
  17. CachedSchemaRegistryClient client = new CachedSchemaRegistryClient(schemaUrl, 20);
  18.  
  19. client.register(subject, avroSchema);
  20. }
Add Comment
Please, Sign In to add comment