2012-05-20 66 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) 
    } 

}