Akka persistence: change serialization for persistenceId


(Ikrom) #1

I’m using akka with akka persistence cassandra. I’ve got many persitenceIds. I want to change serialization method for one of the persistenceIds, for example persistence_id_x. In persistence_id_x there are events and snapshots already. I want to change serialization method for events and snapshot in this persistence_id_x.
What is the recommended way to do it?
I’m thinking about creating new persistenceId and migrate events and snapshots from persistence_id_x. In new persistenceId I’ll use new "case class"es with use different serialization.
I can optimize deleting snapshots from persistence_id_x and migrate only events to new persistence.


(Johan Andrén) #2

The actual event is passed to the Akka serialization infra as is, so that means there is no way to figure out what persistence id it was for in the serializer unless you include the serializer id in your events. With access to that information you could potentially create a serializer that defers to other serializers based on the id, not sure that is a good idea though.

Note that if you introduce a new serialization solution, you could still keep the old one for already serialized events and snapshots, but use the new one to serialize any new events or snapshots.