Quantcast
Channel: Akka Libraries - Discussion Forum for Akka technologies
Viewing all articles
Browse latest Browse all 1362

Cluster singleton to use custom mailbox and dispatcher in typed actor system

$
0
0

In Java, the singleton actor in the system is initialized using the following construct:

ClusterSingleton singleton = ClusterSingleton.get(system);
ActorRef<Counter.Command> proxy =
    singleton.init(SingletonActor.of(Counter.create(), "GlobalCounter"));

Is there a way to pass a custom configuration to select custom mailbox and dispatcher ?

Typically the custom mailbox (and also dispatcher) is set in the config and the actor behavior is spawned using the config selector:

my-app {
  my-special-mailbox {
    mailbox-type = "akka.dispatch.SingleConsumerOnlyUnboundedMailbox"
  }
}
context.spawn(
    childBehavior,
    "from-config-mailbox-child",
    MailboxSelector.fromConfig("my-app.my-special-mailbox"));
context.spawn(
    behavior, "DispatcherFromConfig", DispatcherSelector.fromConfig("your-dispatcher"));

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 1362

Trending Articles