0

看起来我没有正确设置我的演员,但不知道我该怎么做。我设置了一个由 Akka 安排的演员。但是我得到的编译器错误是:not found: value MaidActor

代码:

/**
 * the engine maid
 */
class MaidActor extends Actor {
  def receive = {
    case "ChatMaid" => {
      println("A hot french maid will now clean up the chat database")
    }
  }
}

/**
 * scheduled jobs to run in the background
 */
object EngineJobs {

  /**
   * clean old chats to save database space
   */
  def setupJobs = {
      Akka.system.scheduler.schedule(0 seconds, 120 minutes, MaidActor, "ChatMaid")
  }

}

谢谢你的帮助!

4

1 回答 1

1

我解决了:)

能够通过正确设置我的 EngineJobs 对象来修复它。这是通过ActorSystem像这样创建一个新的来完成的:

/**
 * the engine maid
 */
class MaidActor extends Actor {
  def receive = {
    case "tick" => {
      Logger.info("A hot french maid will now clean up the chat database")
      models.Chat.cleanOldChats
    }
  }
}

/**
 * scheduled jobs to run in the background
 */
object EngineJobs {

  val system = ActorSystem("jobs")
  val Tick = "tick"
  val ChatMaid = system.actorOf(Props(new MaidActor))

  /**
   * set up jobs to be run in engine
   */
  def setupJobs = {
      Akka.system.scheduler.schedule(0 seconds, 10 seconds, ChatMaid, Tick)
  }

}
于 2012-05-20T01:53:06.447 回答