...
- Multicast will implicitly cache streams to ensure that all the endpoints can access the message content
- Dead Letter Channel uses stream caching to ensure that the message content can actually be read again when redelivering a message
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 |
---|---|---|
CamelCachedOutputStreamThreshold | 64kb | 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. |
You set these properties on the CamelContext as shown below:
Code Block | ||||
---|---|---|---|---|
| ||||
context.getProperties().put(CachedOutputStream.TEMP_DIR, "/tmp/cachedir");
context.getProperties().put(CachedOutputStream.THRESHOLD, "1024");
|
Disabling spooling to disk
Available as of *Camel 1.6.2/2.0
You can disable spooling to disk by setting a threshold of 0 or a negative value.
Code Block |
---|
// disable spooling to disk
context.getProperties().put(CachedOutputStream.THRESHOLD, "0");
|
How it works?
In order to determine if a type requires caching, we leverage the type converter feature. Any type that requires stream caching can be converted into an org.apache.camel.StreamCache
instance.