The Akka-2 case should remain in an infinite loop and check every 10 minutes to process the data.
How to create a loop so that the instance invokes itself, checks the operation and then sleeps for an interval?
I also see that it is no longer possible to request a mailbox size. How do you make sure that messages are ignored while the work task is active (in this case, the send function)?
case class Dispatch()
// Automatical start? The start function has been removed since Akka 2 ?
val dispatcher = system.actorOf(Props[MailDispatcher])
class MailDispatcher extends Actor {
private val interval = Config.getLong("mail.check.interval")
context.setReceiveTimeout(Duration(interval, TimeUnit.SECONDS))
def receive = {
case ReceiveTimeout => {
self ! Dispatch
}
case Dispatch => dispatch()
case e: Exception => Logger.error("unexpected Error: " + e)
}
def dispatch() {
}
}
source
share