Re: [akka-user] AKKA persistenceId uniquness

2016-10-24 Thread Ajmal Babu
Patrik, I take that back it is unique across different incarnation, thanks 
for the help.

On Monday, October 24, 2016 at 12:33:16 PM UTC-5, Ajmal Babu wrote:
>
> Thanks Patrik, I would change it to the example you mentioned without the 
> parent. The uniqueness is still only guaranteed to be within a node. For 
> any reason if a restart happens for the actor then the id value will be 
> different from the original value and I hope that is ok.
>
> Ajmal
>
> On Monday, October 24, 2016 at 11:03:26 AM UTC-5, Patrik Nordwall wrote:
>>
>> It must be unique. I'd recommend something like this 
>> http://doc.akka.io/docs/akka/2.4/scala/cluster-sharding.html#An_Example 
>> instead of complicating it with parent.
>>
>> I think the template needs an update.
>>
>> /Patrik
>> mån 24 okt. 2016 kl. 16:41 skrev Ajmal Babu <ajma...@gmail.com>:
>>
>>> 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 akka-user+...@googlegroups.com.
>>> To post to this group, send email to akka...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/akka-user.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>

-- 
>>>>>>>>>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] AKKA persistenceId uniquness

2016-10-24 Thread Ajmal Babu


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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] On cluster node failure is there an automatic way to recover cluster shard persistent actors in the failed node to other node?

2016-09-19 Thread Ajmal Babu
Working on AKKA persistence with cluster sharding and the flag 
akka.cluster.sharding.remember-entities set to "on". For some reason when 
one of the node dies in the cluster the entities in that node does not get 
automatically restarted in the other available nodes in the cluster. Is 
that the expected behavior? Is there an automatic recover-ability on node 
failure to move actors to another node, for such feature what is the right 
way to implement?

-- 
>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] AKKA persistence actor eager loading of journal & snapshot.

2016-09-19 Thread Ajmal Babu
Following options is specified in the AKKA configuration file to eager load 
journals and snapshots for AKKA Cassandra persistence. We have an AKKA and 
persistence actor is started in one of the cluster nodes. but when the node 
dies the persistence actor does not automatically gets recreated on the 
other available nodes in the cluster. Actor gets created only when it is 
invoked the next time not during the node re-balance. Based on the below 
options it seems like eager loading of persistence actor is possible. But 
setting this options does not eagerly load the persistence actor on other 
nodes in the cluster during a node a failure. Can you please point to right 
options in the documentation.


   1. 
   
   persistence {
 journal {
   plugin = "cassandra-journal"
   cassandra-journal.contact-points = ["127.0.0.1"]
   auto-start-journals = ["cassandra-journal"]
 }
   
 snapshot-store {
   plugin = "cassandra-snapshot-store"
   cassandra-snapshot-store.contact-points = ["127.0.0.1"]
   auto-start-snapshot-stores = ["cassandra-snapshot-store"]
 }
   }
   
   2. 
   

-- 
>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Cluster Sharding with remember-entity restarting a stopped actor

2016-09-18 Thread Ajmal Babu
We are using AKKA 2.4.10 persistent actor, cluster sharding with Cassandra 
storage and have enabled remember-entity = true. We need to stop certain 
persistent actor after a specific time-frame. (few days). The issue is that 
the actor once stopped gets automatically restarted after 10 seconds. But 
if remember-entity is set to false it does not restart. The actor stop is 
tried out (a) from another persistent actor or (b) from the same persistent 
actor with a scheduled future event to stop itself. Both cases automatic 
restart happens.

We are using Spring with AKKA. Interestingly if the persistence actor stop 
is performed from direct spring code for e.g. on a rest end point (not from 
an actor code) persistent actor does not get automatically restarted 
irrespective of the above flag remember-entity = true or false. Can you 
please provide solution for this,

-- 
>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.