Add ClusterSingleton supervision documentation (#25419)
* Add ClusterSingleton supervision documentation * Make example code compilable * Changed snip per comment * Back to double snip
This commit is contained in:
parent
7ca7b08694
commit
b1904325ca
4 changed files with 120 additions and 1 deletions
|
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* Copyright (C) 2015-2018 Lightbend Inc. <https://www.lightbend.com>
|
||||
*/
|
||||
|
||||
package jdocs.cluster.singleton;
|
||||
|
||||
import akka.actor.AbstractActor;
|
||||
import akka.actor.ActorRef;
|
||||
import akka.actor.Props;
|
||||
import akka.actor.SupervisorStrategy;
|
||||
|
||||
//#singleton-supervisor-actor-usage-imports
|
||||
import akka.actor.PoisonPill;
|
||||
import akka.actor.Props;
|
||||
import akka.cluster.singleton.ClusterSingletonManager;
|
||||
import akka.cluster.singleton.ClusterSingletonManagerSettings;
|
||||
//#singleton-supervisor-actor-usage-imports
|
||||
|
||||
abstract class ClusterSingletonSupervision extends AbstractActor {
|
||||
|
||||
public ActorRef createSingleton(String name, Props props, SupervisorStrategy supervisorStrategy) {
|
||||
//#singleton-supervisor-actor-usage
|
||||
return getContext().system().actorOf(
|
||||
ClusterSingletonManager.props(
|
||||
Props.create(SupervisorActor.class, () -> new SupervisorActor(props, supervisorStrategy)),
|
||||
PoisonPill.getInstance(),
|
||||
ClusterSingletonManagerSettings.create(getContext().system())),
|
||||
name = name);
|
||||
//#singleton-supervisor-actor-usage
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue