如何取消发布 Akka Camel 消费者?
在我向 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
}
}
My Camel consumer actor won't get unpublished after I sent a message to it. This prevents the application from shutting down. It works if I just start and stop the actor without sending any messages. What am I missing here?
Example code:
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
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论