Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Akka, what is the recommended way to access config parameters from within an UntypedActor

Tags:

java

akka

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.

like image 227
vegemite4me Avatar asked May 11 '12 12:05

vegemite4me


2 Answers

It's either that or taking the value in its constructor, so you don't have a hard dependency on the configuration.

like image 118
Viktor Klang Avatar answered Nov 14 '22 08:11

Viktor Klang


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.

like image 1
erkfel Avatar answered Nov 14 '22 08:11

erkfel