What is the best way to generate persistenceId
from complex key
(String, String) and every part of this key is not controlled (may contain any symbol)?
- If decoding is required
- If decoding is not required (original key stored in actor)
What is the best way to generate persistenceId
from complex key
(String, String) and every part of this key is not controlled (may contain any symbol)?
Copyright © 2021 Jogjafile Inc.
One possibility is to encode the length of the first string of the key as the first characters of the
persistenceId
. An example in Scala:Another would be to use escaping, but that can have a lot of subtleties, despite its initially apparent simplicity.
The specific Akka Persistence backend in use may enforce restrictions on the
persistenceId
(e.g. length of IDs).