Mike U
Mike U

Reputation: 237

Schema registry validation , avro models without inline objects

I am using kafka, springboot, avro, schema registry. My avro schema is complex so some objects are in multiple files.

{
  "namespace": "com.example.avro.model",
  "type": "record",
  "name": "Company",
  "fields": [
    { "name": "name", "type": "string" },
    { "name": "address", "type": "com.example.avro.model.Address"} 
  ]
}

with address being

{
  "namespace": "com.example.avro.model",
  "type": "record",
  "name": "Address",
  "fields": [
    { "name": "city", "type": "string" },
    { "name": "house", "type": "string"} 
  ]
}

My springboot application deploys new version to schema registry thanks to these dependencies:

implementation("org.apache.avro:avro:1.12.0")
implementation("org.apache.kafka:kafka-clients:3.9.0")
implementation("io.confluent:kafka-avro-serializer:7.7.1")

When deployed the Company object gets the Address object declared inline, rather than a separate moodel. When i need to validate new schema I use:

<plugin>
   <groupId>io.confluent</groupId>
   <artifactId>kafka-schema-registry-maven-plugin</artifactId>
   <version>7.7.2</version> <!-- tried 7.8.0 as well -->
   .....
</plugin>

The exception is

Could not parse Avro schema
org.apache.avro.SchemaParseException: Undefined name: "com.example.avro.model.Address"

It is unclear to me if the issue is with the plugin not seeing Address.avsc or the fact that schema-registry has the Company objects with address as an inline definition. Or both? I could use an advice.

It is a simplified objects of my schema. Declaring the Address inline within the Company object is not an option.

Upvotes: 0

Views: 21

Answers (0)

Related Questions