我发送消息后,我的Camel消费者演员不会取消发布。这可以防止应用程序关闭。如果我只是在不发送任何消息的情况下启动和停止actor,它就可以工作我在这里缺少什么?
示例代码:
import akka.actor.Actor
import Actor._
import akka.event.EventHandler
import akka.camel.{CamelContextManager, CamelServiceManager, Message, Consumer}
object Test {
def main(args: Array[String]): Unit = {
val consumer = actorOf(new Actor with Consumer {
def endpointUri = "direct:test"
def receive = {
case msg: Message => println(msg.bodyAs[String])
}
})
val service = CamelServiceManager.startCamelService
service.awaitEndpointActivation(1) {
consumer.start()
}
// If I comment out this row, it works
CamelContextManager.mandatoryTemplate.requestBody("direct:test", "testing")
service.awaitEndpointDeactivation(1) {
consumer.stop()
}
service.stop
}
}