I'm making akka cluster system.
And I called actor 10,000 times for test.
But in received method, I got just 5,000 ~ 7,000 times of event.
What should I do?
Here's my code :
[cluster]
val system = ActorSystem("Cluster_Actor")
val clusterController = system.actorOf(Props[ClusterListener], "clusterController")
val workers = system.actorOf(RoundRobinPool(5).props(Props[ApiActor]), "workers")
ClusterClientReceptionist(system).registerService(workers)
class ApiActor extends Actor{
private implicit val timeout = Timeout(2 seconds)
implicit val ec: ExecutionContext = scala.concurrent.ExecutionContext.global
val dbActor = context.actorSelection("/user/dbController")
override def receive: Receive = {
case param : String =>
println(param) // printed here about 5000 ~ 7000 times
sender() ! param
case _ =>
println("msg!")
}
}
[client]
def test(n : Int) = Action{
for (i <- 1 to n){
actor(i)
}
Ok("")
}
var list : List[Int] = List(0)
def actor(n : Int) = {
val initialContacts = Set(
ActorPath.fromString("akka://[email protected]:2555/system/receptionist"))
val settings = ClusterClientSettings(system).withInitialContacts(initialContacts)
val client = system.actorOf(ClusterClient.props(settings),"client")
val msg = ClusterClient.Send("/user/workers", n.toString, false)
val f = Patterns.ask(client, msg, timeout.duration)
}
question from:
https://stackoverflow.com/questions/65895334/akka-cluster-data-loss 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…