Changed unlimited blocking to block up untill the replyTimeout, and added a test for it, where manual Ack is never received ticket #1926

removed unnecesary methods
This commit is contained in:
RayRoestenburg 2012-09-03 12:08:46 +02:00
parent 112e02e965
commit d0a50f66e7
47 changed files with 1056 additions and 784 deletions

View file

@ -1,15 +1,21 @@
package akka.camel.internal
import akka.actor.ActorSystem
import akka.actor.{ ActorRef, Props, ActorSystem }
import akka.camel.internal.component.{ DurationTypeConverter, ActorComponent }
import org.apache.camel.impl.DefaultCamelContext
import scala.Predef._
import akka.event.Logging
import akka.camel.{ CamelSettings, Camel }
import akka.camel.internal.ActivationProtocol._
import scala.util.control.NonFatal
import scala.concurrent.util.Duration
import org.apache.camel.{ ProducerTemplate, CamelContext }
import scala.concurrent.util.FiniteDuration
import org.apache.camel.ProducerTemplate
import concurrent.{ Future, ExecutionContext }
import akka.util.Timeout
import akka.pattern.ask
import java.io.InputStream
import org.apache.camel.model.RouteDefinition
/**
* For internal use only.
@ -21,16 +27,17 @@ import scala.concurrent.util.FiniteDuration
* Also by not creating extra internal actor system we are conserving resources.
*/
private[camel] class DefaultCamel(val system: ActorSystem) extends Camel {
val supervisor = system.actorOf(Props[CamelSupervisor], "camel-supervisor")
/**
* For internal use only.
*/
private[camel] implicit val log = Logging(system, "Camel")
lazy val context: CamelContext = {
lazy val context: DefaultCamelContext = {
val ctx = new DefaultCamelContext
if (!settings.jmxStatistics) ctx.disableJMX()
ctx.setName(system.name)
ctx.setStreamCaching(true)
ctx.setStreamCaching(settings.streamingCache)
ctx.addComponent("akka", new ActorComponent(this, system))
ctx.getTypeConverterRegistry.addTypeConverter(classOf[FiniteDuration], classOf[String], DurationTypeConverter)
ctx
@ -65,4 +72,46 @@ private[camel] class DefaultCamel(val system: ActorSystem) extends Camel {
}
log.debug("Stopped CamelContext[{}] for ActorSystem[{}]", context.getName, system.name)
}
/**
* Produces a Future with the specified endpoint that will be completed when the endpoint has been activated,
* or if it times out, which will happen after the specified Timeout.
*
* @param endpoint the endpoint to be activated
* @param timeout the timeout for the Future
*/
def activationFutureFor(endpoint: ActorRef)(implicit timeout: Timeout, executor: ExecutionContext): Future[ActorRef] =
(supervisor.ask(AwaitActivation(endpoint))(timeout)).map[ActorRef]({
case EndpointActivated(`endpoint`) endpoint
case EndpointFailedToActivate(`endpoint`, cause) throw cause
})
/**
* Produces a Future which will be completed when the given endpoint has been deactivated or
* or if it times out, which will happen after the specified Timeout.
*
* @param endpoint the endpoint to be deactivated
* @param timeout the timeout of the Future
*/
def deactivationFutureFor(endpoint: ActorRef)(implicit timeout: Timeout, executor: ExecutionContext): Future[ActorRef] =
(supervisor.ask(AwaitDeActivation(endpoint))(timeout)).map[ActorRef]({
case EndpointDeActivated(`endpoint`) endpoint
case EndpointFailedToDeActivate(`endpoint`, cause) throw cause
})
}
/**
* For internal use only.
*/
private[camel] object Conversions {
//FIXME Add this to the configuration, and move this functionality to the Camel Extension.
private val bodyConversions = Map(
"file" -> classOf[InputStream])
def apply(scheme: String, routeDefinition: RouteDefinition): RouteDefinition = bodyConversions.get(scheme) match {
case Some(clazz) routeDefinition.convertBodyTo(clazz)
case None routeDefinition
}
}