Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
299 views
in Technique[技术] by (71.8m points)

actor - akka cluster data loss

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...