On Mon, Jun 6, 2016 at 1:19 PM, kraythe <[email protected]> wrote:

> I have an actor that I would like to use cluster sharing for but the thing
> is that the actor will restore its state from a database in the event of
> migration and so on. So there is no need to journal the messages and thus
> no need for Akka persistence. I have the vast majority of it sorted, but
> what I can't figure out how to pass the entity id to the actor when the
> sharing system creates the actor.
>

Just get it from the Actor's name.  Actors can always see their own name.
That's how I often do it.  (For example, see here
<https://github.com/jducoeur/Querki/blob/master/querki/scalajvm/app/querki/spaces/SpaceRouter.scala#L38>
.)


> I this would be important to bind the actor to the entity so the same
> actor will be consulted later for information on the entity. How can I get
> the sharing system to pass the id to the props when the actor is created?
> Also how can I get the sharing system to create these actors in bulk
> because I might have to start several thousand at once and would rather not
> have to make several thousand DB calls but rather one call.
>

There's nothing built in for this, AFAIK.  Indeed, I don't see how this
would be possible in principle, since the Sharding system has no a priori
concept of all the possible entities.

This actually seems fairly tricky, since it is binding the actors together
in a way that isn't normal for Akka.  My best guess would be to have a
single Actor that does the mammoth DB call, sucks all the data in, and then
when the entities get created by Cluster Sharding they ping that master
data manager for their init data.  (Or something like that.)

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