vegemite4me
vegemite4me

Reputation: 6856

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

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

Answers (2)

erkfel
erkfel

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

Viktor Klang
Viktor Klang

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

Related Questions