Reputation: 6856
I have an UntypedActor
that needs to read a configurable value from application.conf
. The following line works, but seems a bit long winded.
public class FooUntypedActor extends UntypedActor {
private final long bar = context().system().settings().config().getLong("foo.bar");
// other stuff
}
Is this the correct method of getting a configurable value in Akka?
I should probably make it clear that I am using the Java API.
Upvotes: 17
Views: 4478
Reputation: 1658
Akka documentation suggests to create an Extension
and place application specific settings there. The good example for Akka 2.4.7 is specified in the documentation.
Upvotes: 1
Reputation: 26579
It's either that or taking the value in its constructor, so you don't have a hard dependency on the configuration.
Upvotes: 5