开发者

How to unpublish an Akka Camel consumer?

开发者 https://www.devze.com 2023-04-07 01:13 出处:网络
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.

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开发者_C百科 out this row, it works
    CamelContextManager.mandatoryTemplate.requestBody("direct:test", "testing")

    service.awaitEndpointDeactivation(1) {
      consumer.stop()
    }

    service.stop

  }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消