Injecting consistent-hashing-pool actors

84 views
Skip to first unread message

Taner Sener

unread,
Jun 19, 2016, 5:31:21 AM6/19/16
to Akka User List
Hi,

I'm having trouble making consistent-hashing-pool work. I'm using Akka with under Play and inject Akka Actors with Guice. Everything looks fine but according to logs my tasks are executed by default dispatcher. I expect them to be run by hashing-pool. Could you please check my configuration and tell me if I'm missing something?


My application.conf
akka {
    actor {
        deployment {
        ...
            /campaign-activity-router {
                router = consistent-hashing-pool
                nr-of-instances = 10
                virtual-nodes-factor = 10
            }
        }


My module
public class AdsModule extends AbstractModule implements AkkaGuiceSupport {
    public void configure() {
        bindActor(CampaignActivityActor.class, "campaign-activity-router", this::applyActorProps);
    }
   
    private Props applyActorProps(final Props props) {
        return props.withRouter(FromConfig.getInstance().withSupervisorStrategy(newAlwaysRestartOnlyActorSupervisorStrategy()));
    }

    private SupervisorStrategy newAlwaysRestartOnlyActorSupervisorStrategy() {
        return new OneForOneStrategy(-1, Duration.Inf(), throwable -> SupervisorStrategy.restart(), true);
    }  
}

My message class
public class Message implements ConsistentHashingRouter.ConsistentHashable, Serializable {
    private final Subscriber subscriber;

    public Object consistentHashKey() {
        return subscriber.getId();
    }

}

Caller code

@Inject
@Named("campaign-activity-router")
private ActorRef campaignActivityActorRouter;

this.campaignActivityActorRouter.tell...


Thanks

Patrik Nordwall

unread,
Jun 19, 2016, 3:30:40 PM6/19/16
to Akka User List
A router pool means that it creates nr-of-instances actor instances of the given actor props. They will still run on the default dispatcher, unless you specify another dispatcher.

/Patrik
--
>>>>>>>>>> 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+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Taner Sener

unread,
Jun 24, 2016, 6:48:56 PM6/24/16
to Akka User List
I missed the pool part I guess; now it all makes sense.

Thanks


Reply all
Reply to author
Forward
0 new messages