schema-registry icon indicating copy to clipboard operation
schema-registry copied to clipboard

💡 maven schema-registry:register all

Open marchenko1985 opened this issue 4 years ago • 10 comments

In case if we do not want to have all 100+ schemas listed in the subjects section of the plugin configuration

Will be so nice if the plugin will just use everything it can find under outputDirectory if the subjects section missing

image

marchenko1985 avatar Jun 15 '21 06:06 marchenko1985

Similar to #690

OneCricketeer avatar Jun 16 '21 14:06 OneCricketeer

One problem with this is that AVDL record schemas cannot have hyphens, so using TopicNameStrategy registration isn't possible

OneCricketeer avatar Jun 16 '21 14:06 OneCricketeer

@OneCricketeer not sure if I got you right, but after downloading I got a bunch of TopicA-key.avcs, TopicA-value.avcs files, so not sure about AVDL files but, if starting from scratch everything should work fine.

marchenko1985 avatar Jun 16 '21 15:06 marchenko1985

IDL files generate AVSC and can more easily be used for cross-referenced schemas with import support and composition

https://avro.apache.org/docs/current/idl.html

I'm talking about compilation / resource processing via the Avro Maven plugin, not related to the Registry

OneCricketeer avatar Jun 16 '21 15:06 OneCricketeer

Using TopicRecordNameStrategy the list of subject-schema mapping is not just long but also unreadable.

<schemaTypes>
     <my-topic-com.mycompany.avro.schemas.test.Event1>AVRO</my-topic-com.mycompany.avro.schemas.test.Event1>
     <my-topic-com.mycompany.avro.schemas.test.Event2>AVRO</my-topic-com.mycompany.avro.schemas.test.Event2>
</schemaTypes>

It would also be nice to have a schemaType like AVRO-IDL to check schema compatibility from idl files. There is no official maven plugin to convert from avdl files to avsc. The avro-maven-plugin with goal idl-protocol lets you generate classes directly from avdl files. With this setup you don't have avsc files in the project.

Given these two limitations (long mapping list and lack of avdl support) I think this plugin is unusable in a production environment.

Please tell me if I am missing something.

ena1106 avatar Nov 09 '21 08:11 ena1106

The idl-protocol goal does create AVSC files.

In the past, we used it with the exec plugin to define a class and maven goal that iterates over AVDL or AVSC and registers them to the registry

OneCricketeer avatar Nov 09 '21 12:11 OneCricketeer

Can you please tell me where are the AVSC files generated by the idl-protocol goal? I can only see classes under target/generated-sources/avro/classes

Maybe the exec plugin was getting the schemas from the classes? The json string is present in a static variable of generated classes.

ena1106 avatar Nov 09 '21 16:11 ena1106

Well within each class, there's a static SCHEMA$ field that has that information.

But this is what I was referring to http://www.virtualroadside.com/blog/index.php/2014/06/08/automatically-generating-avro-schemata-avsc-files-using-maven/

OneCricketeer avatar Nov 09 '21 19:11 OneCricketeer

I already read that blog post. They generate avsc files with maven-exec and Avro tools library, not using the idl-protocol goal of the avro-maven-plugin.

ena1106 avatar Nov 10 '21 15:11 ena1106

Does that matter? I just couldn't remember which plugins we used. Based on what I have posted, I think we used the exec plugin followed by the avro plugin's schema goal to generate classes, then you can also use Schema Registry maven plugin to register those AVSC as well

OneCricketeer avatar Nov 10 '21 16:11 OneCricketeer