![]() When those techniques are combined, you'll successfully be using schema-less serialization while including a schema identifier. So when you create your custom serializer, you can extend the appropriate trait, define your schema identifier, and use the binary output stream. In either case it is still an Array.)Īkka itself supplies a Serializer trait or a SerializerWithStringManifest trait, which will automatically include a field for a "schema identifier" in the object of whatever you serialize. ('binary' is a bit of a misnomer here since all it does is omit the schema. Or, you can use the binary output stream, which simply omits the schema when serializing each message. Using avro4s, you can use the default data output stream to include the schema with every serialized message. (I don't see how to change the definition of the case class at runtime.)Īfter spending more time on this, here are the answers I came up with. However, for the foreseeable future, this Akka Persistence app is the only app that will be serializing and deserializing these messages, so we don't see a need for a separate schema registry.Ĭhecking the docs for avro and the various scala libs, I see ways to include the schema with messages, and also how to use it "schema-less" by using a schema registry, but what about the in-between case? What's the correct approach for going schema-less, but somehow including an identifier to be able to look up the correct schema (available in the local deployed codebase) for the deserialized object? Would I literally just create a schema that represents my case class, but with an additional "identifier" field for schema version, and then have some sort of in-memory map of identifier->schema at runtime?Īlso, is the correct approach to have one serializer/deserialize class for each version of the schema, so it knows how to translate every version to/from the most recent version?įinally, are there recommendations on how to unit-test schema evolutions? For instance, store a message in akka-persistence, then actually change the definition of the case class, and then kill the actor and make sure it properly evolves. We'd like to avoid including the full schema with every message. We consider it likely that our persisted events will "evolve" over time, so we want to support schema evolution, and are considering Avro first. We are considering a serialization approach for our scala-based Akka Persistence app.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |