On 16/01/17 21:22, Patrik Nordwall wrote:
> You should not serialize PersistentRepr, unless you are using a key-value
> store that can only store one single value per key.
It's a flat file so the concept of columns only exists insofar as I
define it - which is why I was intending to serialize to JSON. Isn't
PersistentRepr saved inside the datastore? If so, how is it normally
serialized, eg in the LevelDB datastore?
> Instead, grab the meta data fields from PersistentRepr and save them
> in separate columns.
Or I could just save the required fields as an outer JSON 'wrapper' over
the application event that's been serialized, perhaps?
> Grab the payload, serialize it, and save its bytes (the json) in a
> separate column.
That doesn't seem to be possible - findSerializerFor can't be passed the
payload as PersistentRepr.payload returns an Any, e.g.
// p is a PersistentRepr
val bytes = ser.findSerializerFor(p.payload).toBinary(p.payload)
does not compile as findSerializerFor expects an AnyRef.
> It's also possible to not use a serializer (bytes) at all and instead use
> an EventAdapter to transform the domain events to json representation (e.g.
> I would imagine this would be efficient for MongoDB and crating BSON
> instead of using bytes).
I did look at EventAdapter but it looked like you still needed to feed
that through a Journal implementation, which is what I'm struggling with
here.
The docs really don't give you much help on how to write a
AsyncWriteJournal - they tell you about the API but I haven't been able
to find any information about how you hook it up with the serializer,
for example.
--
Alan Burlison
--