...
Streams are caching in memory. In Camel 2.0, large stream messages (over 64 Kb in Camel 2.11 or older, and 128 kb from Camel 2.12 onwards) will be cached in a temporary file instead – Camel itself will handle deleting the temporary file once the cached stream is no longer necessary.
...
Code Block | ||||
---|---|---|---|---|
| ||||
<camelContext streamCache="true"> <route> <from uri="jbi:service:http://foo.bar.org/MyService"/> <to uri="jbi:service:http://foo.bar.org/MyOtherService"/> </route> <route streamCache="false"> <from uri="jms:queue:foo"/> <to uri="jms:queue:bar"/> </route> </camelContext> |
Enabling from Java DSL
In Camel 2.0 you You can enable stream cache by setting the property on CamelContext, for instance in a RouteBuilder class:
...
Code Block | ||||
---|---|---|---|---|
| ||||
context.setStreamCache(true); from("jetty:http://0.0.0.0:9090").noStreamCaching() .to("file:target/incoming"); |
Implicitly enabled for multicast and dead letter channel (Camel 1.x)
Some EIPs require that the message content can be read multiple times. Stream caching will be automatically enabled when using these EIPs in your routes:
...
Streaming cache to files
When stream cache is enabled it will by default spool big streams to files instead of keeping them in memory. The default threshold is 64kb but you can configure it with the following properties:
Property | Default | Description |
---|---|---|
CamelCachedOutputStreamBufferSize | 2kb | Camel 2.9.4, 2.10.2, 2.11.0: Size in bytes of the buffer used in the stream. |
CamelCachedOutputStreamThreshold | 64kb or 128kb | 64kb for Camel 2.11 or older. 128kb for Camel 2.12 onwards. Size in bytes when the stream should be spooled to disk instead of keeping in memory. Use a value of 0 or negative to disable it all together so streams is always kept in memory regardless of their size. |
CamelCachedOutputStreamOutputDirectory | java.io.tmpdir | Base directory where temporary files for spooled streams should be stored. |
CamelCachedOutputStreamCipherTransformation | null | Camel 2.11.0: If set, the temporary files are encrypted using the specified cipher transformation (i.e., a valid stream or 8-bit cipher name such as "RC4", "AES/CTR/NoPadding". An empty name "" is treated as null). |
...
Disabling spooling to disk
...
You can disable spooling to disk by setting a threshold of 0 or a negative value.
...