0

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?

  • Have you tried making `object Main` not `extend App` and move `val system` and `system ! Start()` into a `def main`? `extends App` can behave surprisingly. – Levi Ramsey May 14 '22 at 13:44
  • Yes, I did. Sadly, it didn't really help. But what's interesting is I opened my old akka test project and everything works fine there. – validexpress May 14 '22 at 14:15

1 Answers1

1

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.

  • Okay I found the answer here: https://stackoverflow.com/questions/44298847/why-do-we-need-to-add-fork-in-run-true-when-running-spark-sbt-application – validexpress May 14 '22 at 14:21