diff --git a/akka-cluster-sharding-typed/src/main/mima-filters/2.6.5.backwards.excludes/daemon-process-init-overloads.excludes b/akka-cluster-sharding-typed/src/main/mima-filters/2.6.5.backwards.excludes/daemon-process-init-overloads.excludes new file mode 100644 index 0000000000..5b607dd7f1 --- /dev/null +++ b/akka-cluster-sharding-typed/src/main/mima-filters/2.6.5.backwards.excludes/daemon-process-init-overloads.excludes @@ -0,0 +1,3 @@ +# Non-settings stop message overload for Sharded Daemon Process #29081 +ProblemFilters.exclude[ReversedMissingMethodProblem]("akka.cluster.sharding.typed.scaladsl.ShardedDaemonProcess.init") +ProblemFilters.exclude[ReversedMissingMethodProblem]("akka.cluster.sharding.typed.javadsl.ShardedDaemonProcess.init") \ No newline at end of file diff --git a/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/internal/ShardedDaemonProcessImpl.scala b/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/internal/ShardedDaemonProcessImpl.scala index 01233edf86..a5c12d66f1 100644 --- a/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/internal/ShardedDaemonProcessImpl.scala +++ b/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/internal/ShardedDaemonProcessImpl.scala @@ -93,9 +93,12 @@ private[akka] final class ShardedDaemonProcessImpl(system: ActorSystem[_]) import ShardedDaemonProcessImpl._ def init[T](name: String, numberOfInstances: Int, behaviorFactory: Int => Behavior[T])( - implicit classTag: ClassTag[T]): Unit = { + implicit classTag: ClassTag[T]): Unit = init(name, numberOfInstances, behaviorFactory, ShardedDaemonProcessSettings(system), None)(classTag) - } + + override def init[T](name: String, numberOfInstances: Int, behaviorFactory: Int => Behavior[T], stopMessage: T)( + implicit classTag: ClassTag[T]): Unit = + init(name, numberOfInstances, behaviorFactory, ShardedDaemonProcessSettings(system), Some(stopMessage))(classTag) def init[T]( name: String, @@ -153,6 +156,7 @@ private[akka] final class ShardedDaemonProcessImpl(system: ActorSystem[_]) } } + // Java API def init[T]( messageClass: Class[T], name: String, @@ -160,6 +164,15 @@ private[akka] final class ShardedDaemonProcessImpl(system: ActorSystem[_]) behaviorFactory: function.Function[Integer, Behavior[T]]): Unit = init(name, numberOfInstances, n => behaviorFactory(n))(ClassTag(messageClass)) + override def init[T]( + messageClass: Class[T], + name: String, + numberOfInstances: Int, + behaviorFactory: function.Function[Int, Behavior[T]], + stopMessage: T): Unit = + init(name, numberOfInstances, n => behaviorFactory(n), ShardedDaemonProcessSettings(system), Some(stopMessage))( + ClassTag(messageClass)) + def init[T]( messageClass: Class[T], name: String, diff --git a/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/javadsl/ShardedDaemonProcess.scala b/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/javadsl/ShardedDaemonProcess.scala index fbef1bba26..cfead91abf 100644 --- a/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/javadsl/ShardedDaemonProcess.scala +++ b/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/javadsl/ShardedDaemonProcess.scala @@ -45,6 +45,20 @@ abstract class ShardedDaemonProcess { numberOfInstances: Int, behaviorFactory: function.Function[Integer, Behavior[T]]): Unit + /** + * Start a specific number of actors that is then kept alive in the cluster. + * + * @param behaviorFactory Given a unique id of `0` until `numberOfInstance` create the behavior for that actor. + * @param stopMessage sent to the actors when they need to stop because of a rebalance across the nodes of the cluster + * or cluster shutdown. + */ + def init[T]( + messageClass: Class[T], + name: String, + numberOfInstances: Int, + behaviorFactory: function.Function[Int, Behavior[T]], + stopMessage: T): Unit + /** * Start a specific number of actors, each with a unique numeric id in the set, that is then kept alive in the cluster. * @param behaviorFactory Given a unique id of `0` until `numberOfInstance` create the behavior for that actor. diff --git a/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/scaladsl/ShardedDaemonProcess.scala b/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/scaladsl/ShardedDaemonProcess.scala index 9e655f7c1b..1fde851f2e 100644 --- a/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/scaladsl/ShardedDaemonProcess.scala +++ b/akka-cluster-sharding-typed/src/main/scala/akka/cluster/sharding/typed/scaladsl/ShardedDaemonProcess.scala @@ -45,6 +45,16 @@ trait ShardedDaemonProcess extends Extension { javadslSelf: javadsl.ShardedDaemo def init[T](name: String, numberOfInstances: Int, behaviorFactory: Int => Behavior[T])( implicit classTag: ClassTag[T]): Unit + /** + * Start a specific number of actors that is then kept alive in the cluster. + * + * @param behaviorFactory Given a unique id of `0` until `numberOfInstance` create the behavior for that actor. + * @param stopMessage sent to the actors when they need to stop because of a rebalance across the nodes of the cluster + * or cluster shutdown. + */ + def init[T](name: String, numberOfInstances: Int, behaviorFactory: Int => Behavior[T], stopMessage: T)( + implicit classTag: ClassTag[T]): Unit + /** * Start a specific number of actors, each with a unique numeric id in the set, that is then kept alive in the cluster. * @param behaviorFactory Given a unique id of `0` until `numberOfInstance` create the behavior for that actor.