0

I am trying to find a solution where I have AKKA Actor instance containing specific key value pair as instance data. What I need is to be able to update the instance data by targeting it with the key it has. One Actor will have one key and it is unique. I see that consistenthashing will be able to route to specific node containing may be a thousand actors or so but how to deliver to specific actor?

I need to know in java.

Ram
  • 325
  • 4
  • 22

1 Answers1

5

Consistent hashing doesn't necessarily map consistent hash of the message to an actor in 1-1 relation. It's more many-1 relationship - so a single actor can be a routee for many different (in terms of consistent hash produced) messages. It also has different disadvantages:

  • It's pretty weak when it comes to router resizes (as number of actors change, the ranges of hashes they are responsible for also can change, so the same message may be handled by different actor over time)
  • It requires constant presence of actor in memory.

For your case, Cluster Sharding is more likely, what you're looking for.

Bartosz Sypytkowski
  • 7,463
  • 19
  • 36
  • Amazing! that fits the bill with stateful actor, persistence of actor state between shard work and having unique ID to access it.Can the persistenceId be set to anything I want or does it have to be the name.path that is mentioned in the doc? You are Awesome! – Ram May 22 '17 at 16:46
  • 1
    For persistenceId you'll need an unique identifier that remains the same for all incarnations of target actor/entity. Moreover it cannot be supplied via Props (as props are provided only once on shard region construction) and it cannot depend on node address, as this can change over time (due to rebalancing). If you're able to satisfy those requirements somehow, you're good to go. ActorPath is great here, since its suffix is essentially *///* , therefore unique for each entity, but the same across incarnations. – Bartosz Sypytkowski May 22 '17 at 17:17