Just in case anybody is facing similar dilemma. This snippet is working for basic cases. Have not tried all failures yet
private void createCHRouterWithRoutees(){ Set<Routee> routees = new HashSet<Routee>(); for (int i=0;i<WORKER_POOL_SIZE;i++){ ActorRef worker = getContext().actorOf(Props.create(JobWorker.class), "worker-" + String.valueOf(i)) ; getContext().watch(worker); routees.add(new ActorRefRoutee(worker)); } ConsistentHashingRoutingLogic routingLogic = new ConsistentHashingRoutingLogic(getContext().system()); routingLogic = routingLogic.withHashMapper(new JobKeyBasedHashMapper()); router = new Router(routingLogic,routees); } Since the spawned children are death-watched, upon receiving Terminated message, I do following to recreate the routee and add back to router else if (message instanceof Terminated){ //handle routee termination ActorRef terminatedActor = ((Terminated) message).actor(); String terminatedActorName = terminatedActor.path().name(); router = router.removeRoutee(terminatedActor); ActorRef r = getContext().actorOf(Props.create(JobWorker.class), terminatedActorName); getContext().watch(r); router = router.addRoutee(new ActorRefRoutee(r)); } Regards Muthu On Monday, 15 August 2016 18:04:14 UTC+5:30, Muthukumaran Kothandaraman wrote: > > Hi, > > I am using akka 2.4.8 and creating CH Group as following (with my custom > HashMapper) > > Set<String> actorPaths = new HashSet<String>(); > > > for (int i=0;i<WORKER_POOL_SIZE;i++){ > ActorRef worker = getContext().actorOf(Props.create(JobWorker.class), > "jobworker-" + String.valueOf(i)) ; > actorPaths.add(worker.path().toStringWithAddress()); > } > > > getContext().actorOf( > *new* ConsistentHashingGroup(actorPaths) > .withHashMapper(new JobKeyBasedHashMapper()) > .props(), > "jobrouter"); > > > Now, assuming I have a death-watch on routees and recreate the same upon > Terminated message, will it be added automatically to the group ? > > > If not, is there any other alternative approach using CH Group ? > > > One way I could think of is to use plain Router with > ConsistentHashingRoutingLogic. But I could not figure out how to inject my > custom hashing based on message into ConsistentHashingRoutingLogic. > > > Regards > > Muthu > > > > > > > > > -- >>>>>>>>>> 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 akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.