You do something like this:
```
ClusterSharding.get(system).start("Counter",
  Props.create(Counter.class), settings, messageExtractor);
```

That "Counter" name is what I call the entity type name. I thought you were
trying to get to that via context().parent().parent(), which should not be
necessary.

On Fri, Feb 12, 2016 at 12:26 PM, Bert Robben <[email protected]> wrote:

> I'm not sure what you mean with "entity type name" and grandpa.
>
>
> But I checked the docs again, and it indeed is already mentioned that the
> name is the entityId. I must have overlooked that.
>
> Bert
>
> On Fri, Feb 12, 2016 at 12:14 PM, Patrik Nordwall <
> [email protected]> wrote:
>
>> I think it is documented that the entity id is the actor name. You are
>> welcome to contribute with clarifications with a pull request if you like.
>>
>> The entity type name should be well know by your application. A constant
>> or you can pass it as a constructor parameter via the Props. No need to
>> involve grandpa.
>>
>> fre 12 feb. 2016 kl. 11:43 skrev Bert Robben <[email protected]>:
>>
>>> Thanks Filippo. I think I figured out now what was going wrong.
>>>
>>> I was confused between the shardId and the entityId.
>>>
>>> shardId == context().parent().path().name()
>>> entityId == self().parth().name()
>>>
>>> My entities were being created again and again because I was computing
>>> the entityId wrongly. In my case, all messages carry an id. What I need is
>>> entityId = hash(messageId) and shardId = hash(entityId). However, I was
>>> doing entityId = messageId and shardId = hash(messageId). Therefore I was
>>> always creating a new entity because the messageId is unique. I've fixed my
>>> MessageExtractor now and everything goes as it should.
>>>
>>> thanks,
>>>
>>> Bert
>>>
>>>
>>> On Thursday, February 11, 2016 at 5:36:17 PM UTC+1, Bert Robben 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].
>>> 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.
>>>
>> --
>> >>>>>>>>>> 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 a topic in the
>> Google Groups "Akka User List" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/akka-user/njCIQqOJTrw/unsubscribe.
>> To unsubscribe from this group and all its topics, 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.
>>
>
> --
> >>>>>>>>>> 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.
>



-- 

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