0

How to create two different type actors in a single Akka Cluster.

ActorRef ShardRegion=ClusterSharding.get(ClusterSys).start("Test", Props.create(ShardActor.class), settings,new ShardMessageExtrater());

Here when we start e ShardRegion we define the class it take to create entity actor.
Can we use two type of actor class to create entity Actors?
Any other way?

Arun
  • 67
  • 11
  • 2
    start more than one ShardRegion e.g one for TransactionEntityActor and one for UserEntityActor, so you end up with two shard regions in the same cluster – mForest Jun 17 '22 at 11:05
  • Shards also created for them seperately? for each shard Region?like shard 1 for TransactionEntityActor and shard 1 for UserEntityActor ? – Arun Jun 17 '22 at 11:41
  • And can we send messages from TransactionEntityActor to UserEntityActor and vise versa? – Arun Jun 17 '22 at 11:50
  • 2
    yes for both questions. For send messages you need to provide region actorRef – mForest Jun 17 '22 at 13:01
  • The shard id 1 for TransactionEntityActor and shard id 1 for UserEntityActor will be on same node? – Arun Jun 17 '22 at 13:17
  • 1
    no, there is no such guarantee – mForest Jun 17 '22 at 14:04
  • To make a shard 1 of each type of entity actor how can we handle?Should we handle it in code of Entity actor with different behavior? Or any other way to do this? – Arun Jun 20 '22 at 05:28
  • It seems to me that the best solution is to create an actor with children (one for one entity type) and then route command to specific actor from parent. – mForest Jun 20 '22 at 09:59
  • Children actor will created on same Shard???? – Arun Jun 22 '22 at 06:33
  • yes, they will be children of entity actor – mForest Jun 22 '22 at 09:26

0 Answers0