2018-10-29 17:19:37 +08:00
|
|
|
/*
|
2019-01-02 18:55:26 +08:00
|
|
|
* Copyright (C) 2009-2019 Lightbend Inc. <https://www.lightbend.com>
|
2012-09-03 12:08:46 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package akka.camel.internal
|
|
|
|
|
|
2012-09-26 17:12:30 +02:00
|
|
|
import akka.actor._
|
2012-09-03 12:08:46 +02:00
|
|
|
import akka.camel._
|
2012-09-26 17:12:30 +02:00
|
|
|
import akka.camel.internal.component.CamelPath
|
2012-09-03 12:08:46 +02:00
|
|
|
import org.apache.camel.builder.RouteBuilder
|
|
|
|
|
import org.apache.camel.model.RouteDefinition
|
|
|
|
|
|
2014-02-14 13:06:35 +01:00
|
|
|
import scala.language.existentials
|
|
|
|
|
|
2012-09-03 12:08:46 +02:00
|
|
|
/**
|
2013-06-27 16:45:47 +02:00
|
|
|
* INTERNAL API
|
2012-09-03 12:08:46 +02:00
|
|
|
* Builder of a route to a target which can be an actor.
|
|
|
|
|
*
|
|
|
|
|
* @param endpointUri endpoint URI of the consumer actor.
|
|
|
|
|
*
|
2012-11-24 18:08:34 +01:00
|
|
|
*
|
2012-09-03 12:08:46 +02:00
|
|
|
*/
|
2012-09-26 17:12:30 +02:00
|
|
|
private[camel] class ConsumerActorRouteBuilder(endpointUri: String, consumer: ActorRef, config: ConsumerConfig, settings: CamelSettings) extends RouteBuilder {
|
2012-09-03 12:08:46 +02:00
|
|
|
|
|
|
|
|
protected def targetActorUri = CamelPath.toUri(consumer, config.autoAck, config.replyTimeout)
|
|
|
|
|
|
2012-09-26 17:12:30 +02:00
|
|
|
def configure(): Unit =
|
|
|
|
|
applyUserRouteCustomization(
|
2012-09-27 12:11:45 +02:00
|
|
|
settings.Conversions.apply(
|
2012-09-26 17:12:30 +02:00
|
|
|
endpointUri take endpointUri.indexOf(":"), // e.g. "http" from "http://whatever/..."
|
|
|
|
|
from(endpointUri).routeId(consumer.path.toString))).to(targetActorUri)
|
2012-09-03 12:08:46 +02:00
|
|
|
|
|
|
|
|
def applyUserRouteCustomization(rd: RouteDefinition) = config.onRouteDefinition(rd)
|
|
|
|
|
}
|