Closed 1ambda closed 2 years ago
Hello, I am trying to understand.
The consumers are reading form Avro and use FromAvroConfig
therefore they can use provideReaderSchema
, right?
When using ToAvroConfig you are the producer and there is no reading happening, so don't know what would be the reader schema used for?
Hi! Thanks for the reply.
I am using auto-generated avro class which embeds JSON avro schema. For instance,
@org.apache.avro.specific.AvroGenerated
public class Inventory extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
private static final long serialVersionUID = -3307908315669412535L;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Inventory\"... "); // JSON schema
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
So I thought, we can provide the embedded schema like
val configAvro: ToAvroConfig = AbrisConfig
.toConfluentAvro
.provideSchema(Inventory.getStringifiedJsonSchema(), registryId) // use auto-generated class's JSON schema here
...
I think it's better to describe the current use-case in my team for understanding.
streamOriginal.union(StreamOperation).foreachPartition( ... )
Since I am new to confluent SR, I might misunderstand the architecture. Please let me know If It's impossible.
Thanks
Sorry for late response.
I think you can use:
ToAvroConfig
.withSchema(Inventory.getStringifiedJsonSchema())
.withSchemaId(registryId)
This will create Abris configuration without trying to connect to schema registry at all. So it's your responsibility to make sure the reader is able to get the schema by the id you provided.
Thanks for the information. Would be really helpful.
Hi, Thanks for the great open source. This project saved me today :)
It would be nice to support the
provideReaderSchema
function while buildingToAvroConfig
. Currently it's only supported byFromAvroConfig
.The reason why it's useful is,
Thanks!