Hi, we're building an analytics service where we receive an event name and
properties and we want to produce avro messages in kafka. The schema for
these event properties will be present in confluent's schema registry.

Now since we receive json from web and mobile clients without any schema,
we'll have to lookup the schema from schema registry. But there can be
older versions of apps in the wild producing events with old schema. To
successfully produce avro messages, we'll have to pull all schema versions
from registry and try them one by one. This is something we want to avoid
for performance.

My question is, is it possible to serialize json to avro using a newer
schema? For eg.

old json: {"name": "foo", "number": 1}
newer schema:

{"namespace": "example.avro",
 "type": "record",
 "name": "user",
 "fields": [
     {"name": "name", "type": "string"},
     {"name": "number",  "type": "int"},
     {"name": "color", "type": "string", "default": "green"}
 ]
}

If this was possible, we could simply get the latest schema from schema
registry and fit the json to it to produce an avro record.

Thanks


-- 
Navgeet Agrawal

Reply via email to