Reputation: 83
I have a Scala (2.11.x), Play 2.5.10 application. Within this application, I have various Akka actors which read and write data to the database. I am terminating these actors via a lifecycle stop hook as described in the docs. For one of these actors, before sending in the PoisonPill
to terminate it, I'd like to send it a message to make one final write to the database. However, I'm receiving an exception because the database connections have already been terminated (sometimes, it's a race condition) when that message is received.
Is there a way to control the lifecycle shutdown hook execution order in Play?
Upvotes: 1
Views: 461
Reputation: 8413
In the scaladoc it says:
Stop hooks are executed when the application is shutdown, in reverse from when they were registered.
So, not really.
You might be able to handle it purely from within your actors though. Here's a guide on how to coordinate shutdown in an actor system. I'm not sure how well this integrates with your play-based application though: http://letitcrash.com/post/30165507578/shutdown-patterns-in-akka-2
Upvotes: 2