diff --git a/akka-camel/src/main/scala/CamelContextLifecycle.scala b/akka-camel/src/main/scala/CamelContextLifecycle.scala index b9a696207c..95304b1a6f 100644 --- a/akka-camel/src/main/scala/CamelContextLifecycle.scala +++ b/akka-camel/src/main/scala/CamelContextLifecycle.scala @@ -75,10 +75,13 @@ trait CamelContextLifecycle extends Logging { def init: Unit = init(new DefaultCamelContext) /** - * Initializes this lifecycle object with the given CamelContext. + * Initializes this lifecycle object with the given CamelContext. For the passed + * CamelContext stream-caching is enabled. If applications want to disable stream- + * caching they can do so after this method returned and prior to calling start. */ def init(context: CamelContext) { this.context = context + this.context.setStreamCaching(true) this.template = context.createProducerTemplate _initialized = true log.info("Camel context initialized") diff --git a/akka-camel/src/main/scala/service/CamelService.scala b/akka-camel/src/main/scala/service/CamelService.scala index 566700a737..80fa603897 100644 --- a/akka-camel/src/main/scala/service/CamelService.scala +++ b/akka-camel/src/main/scala/service/CamelService.scala @@ -35,9 +35,6 @@ trait CamelService extends Bootable with Logging { if (!initialized) init if (!started) start - // Camel should cache input streams - context.setStreamCaching(true) - // start actor that exposes consumer actors via Camel endpoints consumerPublisher.start diff --git a/akka-camel/src/test/scala/CamelContextLifecycleTest.scala b/akka-camel/src/test/scala/CamelContextLifecycleTest.scala index b61db27878..e75329f5e9 100644 --- a/akka-camel/src/test/scala/CamelContextLifecycleTest.scala +++ b/akka-camel/src/test/scala/CamelContextLifecycleTest.scala @@ -8,7 +8,10 @@ class CamelContextLifecycleTest extends JUnitSuite with CamelContextLifecycle { @Test def shouldManageCustomCamelContext { assert(context === null) assert(template === null) - init(new TestCamelContext) + val ctx = new TestCamelContext + assert(ctx.isStreamCaching === false) + init(ctx) + assert(context.isStreamCaching === true) assert(!context.asInstanceOf[TestCamelContext].isStarted) assert(!template.asInstanceOf[DefaultProducerTemplate].isStarted) start