camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aidatechinc <HFAO...@AIDATECH.COM>
Subject akka camel route shutdown
Date Sun, 15 Feb 2015 20:51:29 GMT
Hello,
  I am trying to leverage akka to initiate one single camel route execution,
as such once the actor gets a message, it initiates the camel route, and
upon completion, shutdown the route.  Example below, though I am not able to
achieve it.  Either the camel route stays and if I try to shut it down, the
route is never complete.  Any ideas I would appreciate...

class CamelRouteExecutor extends Actor with ActorLogging {

  implicit val system = context.system

  val camel = CamelExtension(system)

  def receive = {

    case work:Any =>

      val route = work.asInstanceOf[java.lang.String]
      log.debug("Executing camel route {}", route)
      val is = new ByteArrayInputStream(route.toString().getBytes())
      val routesDef = camel.context.loadRoutesDefinition(is)
      camel.context.addRouteDefinition(routesDef.getRoutes.get(0))
      log.debug("stopping route Id {} from camel context",
routesDef.getRoutes.get(0).getId)
      camel.context.stopRoute(routesDef.getRoutes.get(0).getId)
      camel.context.removeRoute(routesDef.getRoutes.get(0).getId)

      sender() ! Worker.WorkComplete("work status: ")


    case _ =>
      log.warning("got a message, which I don't understand")
  }
}



--
View this message in context: http://camel.465427.n5.nabble.com/akka-camel-route-shutdown-tp5762782.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message