title: Pausing an actor in Akka
body: <p>I have an actor in Akka that will process messages to create certain entities. Some fields on these entities are computed based on the state of other entities in the database at the moment of creation.</p>
  
  <p>I would like to avoid creating a race condition where the actor processing goes faster than the database is able to persist the entities. This may lead to inconsistent data, going like:</p>
  
  <ul>
  <li>Actor creates a <code>Foo</code> and sends it to other actors for further processing and saving</li>
  <li>The actor is asked to create another <code>Foo</code>. Since the first one is not yet saved, the new one is created based on the old content of the DB, thereby creating a wrong <code>Foo</code>.</li>
  </ul>
  
  <p>Now, this possibility is quite remote, since the creation of the <code>Foo</code>s will be triggered manually. But it is still conceivable that a double click may cause problems under high load. And who knows if tomorrow <code>Foo</code> will be created automatically.</p>
  
  <p>Hence, what I need is some way to tell the actor to wait, and resume its operations only after confirmation that the <code>Foo</code>s have been saved.</p>
  
  <blockquote>
    <p>Is there a way to put an actor in idle state, and tell it to resume its operations after a while?</p>
  </blockquote>
  
  <p>Basically, I would like to use the mailbox as a message queue, and have control over the processing speed of the queue.</p>