Home > Back-end >  Why my Akka main actor stops even though behavior doesn't change?
Why my Akka main actor stops even though behavior doesn't change?

Time:05-19

I have written a small application, but there is a problem that my app doesn't wait for my actors to stop, and stops them before their actions are completed.

I tried to make minimal ActorSystem looking like this:

object Main extends App {
    final case class Start()

    def apply(): Behavior[Start] = {
        Behaviors.setup { context =>
            Behaviors.receiveMessage { message =>
                Behaviors.same
            }
        } 
    }
    val system: ActorSystem[Start] = ActorSystem(Main(), "test")
    system ! Start()
}

But the problem still occurs so there isn't a problem with the rest of application. I thought that ActorSystem is supposed to be running until it's stopped? Isn't that right?

CodePudding user response:

Okay, I found out what the problem was. I was missing fork := true in my build.sbt file. But I still don't understand why it was the problem.

  • Related