confluentinc / confluent-kafka-dotnet

Confluent's Apache Kafka .NET client
https://github.com/confluentinc/confluent-kafka-dotnet/wiki
Apache License 2.0
78 stars 866 forks source link

Is there a way to Deserialise without SchemaRegistry #1099

Open m1nkeh opened 5 years ago

m1nkeh commented 5 years ago

Hello,

I am evaluating some things with Confluent dotnet, and although we plan to use schema registry eventually, this is currently not something we are using at this stage, but I cannot, for the life of me, figure out how to deserialize a message in a way that doesn't require the schema registry.. i.e.

.SetValueDeserializer(new AvroDeserializer<GenericRecord>(schemaRegistry).AsSyncOverAsync())

there are really a couple of questions here:

  1. I know the schema, it's temporarily in a *.json file, and i want to use it for deserialization.. where do i specify this.

  2. As there is no schemaRegistry property, do i need to put something in its place, or can i not use this syntax at all? I.e. not use Confluent.SchemaRegistry or Confluent.SchemaRegistry.SerDes

  3. Is there a Deserializer hidden in Confluent.Kafka pkg that i haven't found yet?

mhowlett commented 5 years ago

you could write your own implementation of ISchemaRegistryClient that works with hard coded schemas locally.

Given my interpretation of your situation, I would recommend considering protobuf or json:

m1nkeh commented 5 years ago

thanks for the reply, bit confused though.. so from your comment i assume this isn't a supported situation.. it's schema registry or bust?

what i mean by 'at this stage' is simply not this sprint, but probably a few weeks (3 or 4). It's not in the far off future.. but it could get delayed as i am not involved in setting things up.

we know the schemas of the Avros being sent, this feels like it should be something that is do-able from a 'stepping stone' sort of standpoint, i.e. lets get the process working, and then we can turn on schema registry later - maybe i am mis-interpreting the usage of Kafka & schema registry though.. i thought it was optional, even with Avro?

montiver0311 commented 4 years ago

I was hoping you can pass in a file and bypass the Schema Registry Url. We don't have a Schema Registry. I am simply trying to consume a stream api from a third party vendor. The message body is encoded using Avro.

This code is from the examples. Does this not allow you to read from a file therefore bypassing Schema Registry?

// var s = (RecordSchema)RecordSchema.Parse(File.ReadAllText("my-schema.json")); var s = (RecordSchema)RecordSchema.Parse( @"{ ""namespace"": ""Confluent.Kafka.Examples.AvroSpecific"", ""type"": ""record"", ""name"": ""User"", ""fields"": [ {""name"": ""name"", ""type"": ""string""}, {""name"": ""favorite_number"", ""type"": [""int"", ""null""]}, {""name"": ""favorite_color"", ""type"": [""string"", ""null""]} ] }" );