/** * Register a schema to the Kafka schema registry under the provided input name. This method will change the name * of the schema to the provided name if configured to do so. This is useful because certain services (like Gobblin kafka adaptor and * Camus) get the schema for a topic by querying for the latest schema with the topic name, requiring the topic * name and schema name to match for all topics. If it is not configured to switch names, this is useful for the case * where the Kafka topic and Avro schema names do not match. This method registers the schema to the schema registry in such a * way that any schema can be written to any topic. * * @param schema {@link org.apache.avro.Schema} to register. * @param name Name of the schema when registerd to the schema registry. This name should match the name * of the topic where instances will be published. * @return schema ID of the registered schema. * @throws SchemaRegistryException if registration failed */ @Override public MD5Digest register(String name, Schema schema) throws SchemaRegistryException { PostMethod post = new PostMethod(url); if (this.switchTopicNames) { return register(AvroUtils.switchName(schema, name), post); } else { post.addParameter("name", name); return register(schema, post); } }
/** * Register a schema to the Kafka schema registry under the provided input name. This method will change the name * of the schema to the provided name if configured to do so. This is useful because certain services (like Gobblin kafka adaptor and * Camus) get the schema for a topic by querying for the latest schema with the topic name, requiring the topic * name and schema name to match for all topics. If it is not configured to switch names, this is useful for the case * where the Kafka topic and Avro schema names do not match. This method registers the schema to the schema registry in such a * way that any schema can be written to any topic. * * @param schema {@link org.apache.avro.Schema} to register. * @param name Name of the schema when registerd to the schema registry. This name should match the name * of the topic where instances will be published. * @return schema ID of the registered schema. * @throws SchemaRegistryException if registration failed */ @Override public MD5Digest register(String name, Schema schema) throws SchemaRegistryException { PostMethod post = new PostMethod(url); if (this.switchTopicNames) { return register(AvroUtils.switchName(schema, name), post); } else { post.addParameter("name", name); return register(schema, post); } }