Injecting Dependencies to Workers in Akka Routers

8 views
Skip to first unread message

Sergio Moreno

unread,
Oct 2, 2015, 3:01:14 PM10/2/15
to play-framework
Hi all!

I have an application where I have a pool of routers, and the routers serve as workers to save things to a DB. 
Currently I am binding my actor from the configuration as follows:
protected void configure() {
    Function<Props,Props> props = p -> FromConfig.getInstance()
            .props(Props.create(DBActor.class));
    bindActor(FactualPlacesIndexerActor.class, "dbRouter",props);
}

However I am having trouble injecting the DB to the actor. For now I am using a configuration message that gets broadcasted upon creation, but I would much rather have the children created with the dependency. @jroper I was looking at using https://github.com/playframework/playframework/blob/master/framework/src/play/src/main/java/play/libs/akka/InjectedActorSupport.java but I can't see how I could here since I don't have control over the creation mechanism, and this can't call the factory methods. 

Any help would be greatly appreciated!

Sergio Moreno

Reply all
Reply to author
Forward
0 new messages