2012-05-20 33 views
0

看起来我没有正确设置我的演员,但不知道我该怎么做。我成立了一个由Akka安排的演员。不过我正在编译器错误是:not found: value MaidActorAkka调度程序找不到我的演员?

代码:

/** 
* 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") 
    } 

} 

感谢您的帮助!

回答

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) 
    } 

}