What is the right way to define persistenceId in AKKA persistence with
cluster sharding? The activator example provides the below option to create
a persistenceId and I like this option (explained later).
override def persistenceId: String = self.path.parent.name + "-" +
self.path.name
But, when you refer to akka.persistence.PersistenceIdentity trait the
documentation says below and it concerns me a little bit.
*trait PersistenceIdentity {*
* /***
* * Id of the persistent entity for which messages should be replayed.*
* */*
* def persistenceId: String*
* ....*
*}*
The way I read the above documentations it feels like the ID has to be
really unique including when shard failure and restart of the entity
happens across another node. But if you see the lightbend activator example
it generates unique value which includes a hashed memory address of the
actor. But if the actor gets recreated on another node because of a node
failure the above Id would be still unique within that node, but will have
a different id from the original id, because the hashed portion is
different in the restarted node. Would that be ok? Will the actor gets
restarted and event replayed correctly?
The reason I am asking this question is that I would like to use this
activator style persistenceId definition because when I start the cluster
shard regions in each node during the nodes start up. I would not know
unique persistenceIds of all shard entities. I would only know the shardId
and entityId at runtime from the messages which gets passed into while
accessing the sharded actor.
The light-bend examples are working correctly with replay of event sourced
data on node failure/restarts. Please advise if it is ok to define the
persistenceId as shown in the light-bend example code?
Note - If that is the case then what would be the significance of the
abstract method persistenceId can’t there be a default implementation that
guarantees uniqueness as shown in light-bend example?
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.