Hi Patrik,

Yes, I've found out my mistake. I was confusing shardId with entityId.

shardId = context().parent().path().name()
entityId = self().path().name()

(you might want to add this to the documentation, because I was confused 
for a while in how the entity would be able to know its own id)

In my app, I wanted to have entityId = hash(messageId) and shardId = 
hash(hash(entityId)). But I had it as entityId = messageId and shardId = 
hash(entityId). Because of this always a new entity was being created as 
the messageId is always different. I've now fixed the messageExtractor and 
now everything works as expected and as it should.

thanks,

Bert

PS: I thought I already sent a reply for this this morning, so if that one 
turns up again this is a duplicate ...

On Friday, February 12, 2016 at 10:48:55 AM UTC+1, Patrik Nordwall wrote:
>
> The name of the actor is the entity identifier (utf-8 URL-encoded), i.e. 
> `self().path().name()`.
> I don't know why you are suggesting `parent()`.
>
> Those actors are not stopped automatically unless there is a rebalance, so 
> that must be something you do.
>
> On Thu, Feb 11, 2016 at 9:52 PM, Filippo De Luca <[email protected] 
> <javascript:>> wrote:
>
>> Hi Bert,
>> the only way that I am aware of to get the id is using the one you have 
>> posted:
>>
>>    context().parent().path().name()
>>
>> It is weird that the Actors get destroyed. They should not by default.
>>
>> On 11 February 2016 at 16:19, Bert Robben <[email protected] 
>> <javascript:>> wrote:
>>
>>> Hi,
>>>
>>> I'm trying to use sharding and that works reasonably well (my entities 
>>> are being created across my cluster and they respond to my requests).
>>>
>>> However, I notice that after each call to my entity, it is destroyed. 
>>> Every next call on the entity then recreates it. This is not ideal for me 
>>> since restarting my entity is a heavy process (I might need to recover lots 
>>> of state from the database). So I would like to tune the system such that 
>>> my entities are survive for much longer (they are perfectly suited to 
>>> handle many concurrent requests). Is this somehow possible with the current 
>>> implementation?
>>>
>>> Note that I use state-store-mode = ddata and I don't make use of Akka 
>>> Persistence.
>>>
>>>
>>> Also, in my case it is vital for my entity to know its id, because 
>>> that's how it discerns itself from the other entities. The only way I've 
>>> found to get to the id now is to do context().parent().path().name(). That 
>>> works, but feels very implementation dependent. Am I missing some easier 
>>> API?
>>>
>>>
>>> thanks,
>>>
>>> Bert
>>>
>>> -- 
>>> >>>>>>>>>> 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] <javascript:>.
>>> To post to this group, send email to [email protected] 
>>> <javascript:>.
>>> Visit this group at https://groups.google.com/group/akka-user.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> -- 
>>  
>>
>> [image: --]
>> Filippo De Luca
>> [image: http://]about.me/FilippoDeLuca
>> <http://about.me/FilippoDeLuca?promo=email_sig>  
>>  
>>
>> -- 
>> >>>>>>>>>> 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] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
>
> Patrik Nordwall
> Typesafe <http://typesafe.com/> -  Reactive apps on the JVM
> Twitter: @patriknw
>
>

-- 
>>>>>>>>>>      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.

Reply via email to