akka shutdown pattern

41 views
Skip to first unread message

mohanraj nagasamy

unread,
Sep 29, 2016, 2:14:53 PM9/29/16
to Akka User List
Hi,

Im working on an play app that sends message to akka actors. In our env, continues deploy happens multiple times a day where severs go down for deploying. 

Question:
How do I make sure that all the messages being processed before restart/shutdown the play application?
Do I have to use at-least once delivery message grantee?

I have a sample project and readme: 

Controllers
===========

- CountController.scala:

Sends 10 messages to ProcessCounter and processes one by one. How do I make sure that all the messages being processing?


Thanks,
Mohan

Jean-François Côté

unread,
Sep 30, 2016, 1:00:22 PM9/30/16
to Akka User List
Hi,

Actor system is built to support failure, this time it can be the deployment, the other time a network failure, etc. You never know. You must code something in the backend that will  handle the retrying and wait for a completion message and then update its state to "completed". If your server restart, you just have to go through the "uncompleted" task and send them again in the actor system.

For example, you could add a "Command" table in your database and create a new entry for each command with the state. When you receive the result from your ProcessCounter actor, you put the state of the command to "Completed". You add a function on the server start to run every "Command" that is not set to "completed".

Hope it helps!
J-F
Reply all
Reply to author
Forward
0 new messages