그래서 저는 다른 쾌적한 몇 가지 서비스와 상호 작용하는 (또는 곧 작동 할 예정인) RESTful 게임 앱을 보유하고 있습니다.재생 프레임 워크 스칼라 응용 프로그램이 시작되면 Runnable RabbitMQ 리스너를 어떻게 시작합니까?
그러나 재생 시작 직후 내 Runnable RabbitMQ 클래스를 시작해야만 일부 akka 배우가 작업을 수행 할 수 있습니다.
지금까지 응용 프로그램에 "GET"경로// 상태에 응답하고 모두 좋았지 만 Play에서 백그라운드 작업을 수행하는 방법으로 "예약 된 작업"에 계속 연결되었습니다. 그렇게하는 것이 옳은가?
system.scheduler().scheduleOnce()
??
로 여기 제안 : Running a continuous background task in Play 2.4.2 server
편집 : Lief 에릭슨은 무엇을 제안하려고하지만 오류 얻을 :
//@Singleton Get the error below when I uncomment this <<-----
class Test extends Runnable {
val logger: Logger = LoggerFactory.getLogger(this.getClass.getName)
def run() = {
while(true) {
logger.info("I'm here #################")
Thread.sleep(10000)
}
}
}
class Bindings extends AbstractModule {
val logger: Logger = LoggerFactory.getLogger(this.getClass.getName)
override def configure() = {
logger.info("Configuring application ....")
bind(classOf[Test]).asEagerSingleton()
}
}
오류 :
[error] C:\PROJECTS\active\voldemort\app\controllers\Application.scala:29: trait Singleton is abstract; cannot be instantiated
[error] @Singleton
[error]^
을하지만 난 주석 때 싱글 톤 데코레이터, 로그 메시지가 나타납니다. "Configuring application ..."
당신이 Guice Module
사용하여 해당 클래스 열심히 부하를 확인해야합니다, 그리고
@Singleton
class RabbitListener(listener: Listener[T]) {
listener.run()
...
}
: OT I'm here #########
로그 행
또 다른 대안 : GlobalSettings를 확장하고 그렇게해야합니까? – dlite922