Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Option

Default

Description

spoolDirectory

${java.io.tmpdir}/camel/camel-tmp-#uuid#

Base directory where temporary files for spooled streams should be stored. This option supports naming patterns as documented below.

spoolChiper

null

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).

spoolThreshold

128kb

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.

spoolHeapMemoryWatermarkThreshold spoolUsedHeapMemoryThreshold

0

A percentage (1 to 99) of current used heap memory to use as threshold for spooling streams to disk. The upper bounds is based on heap committed (guaranteed memory the JVM can claim). This can be used to spool to disk when running low on memory.

spoolUsedHeapMemoryLimit

Max

If spoolUsedHeapMemoryThreshold is in use, then whether the used heap memory upper limit is either Max or Committed.

anySpoolRules

false

Whether any or all SpoolRule}}s must return {{true to determine if the stream should be spooled or not. This can be used as applying AND/OR binary logic to all the rules. By default its AND based.

bufferSize

4096

Initial size if in-memory created stream buffers.

removeSpoolDirectoryWhenStopping

true

Whether to remove the spool directory when stopping CamelContext.

statisticsEnabled

false

Whether utilization statistics is enabled. By enabling this you can see these statics for example with JMX.

...

The following patterns is supported:

  • #uuid# = a random UUID
  • #camelId# = the CamelContext id (eg the name)
  • #name# - same as #camelId#
  • #counter# - an incrementing counter
  • #bundleId# - the OSGi bundle id (only for OSGi environments)
  • #symbolicName# - the OSGi symbolic name (only for OSGi environments)
  • #version# - the OSGi bundle version (only for OSGi environments)
  • ${env:key} - the environment variable with the key
  • ${key} - the JVM system property with the key

A could of examples, to store in the java temp directory with a sub directory using the CamelContext name:

...

Code Block
xml
xml
<!-- define a bean of type StreamCachingStrategy which CamelContext will automatic use -->
<bean id="streamStrategy" class="org.apache.camel.impl.DefaultStreamCachingStrategy">
  <property name="spoolDirectory" value="/tmp/cachedir"/>
  <property name="spoolThreshold" value="65536"/>
  <property name="bufferSize" value="16384"/>
</bean>

<!-- remember to enable stream caching -->
<camelContext streamCaching="true" xmlns="http://camel.apache.org/schema/spring">

Using

...

spoolUsedHeapMemoryThreshold

By default stream caching will spool only big payloads (128kb or bigger) to disk. However you can also set the spoolHeapMemoryWatermarkThreshold spoolUsedHeapMemoryThreshold option which is a percentage of used heap memory. This can be used to also spool to disk when running low on memory.

...

Code Block
    <streamCaching id="myCacheConfig" spoolDirectory="/tmp/cachedir" spoolHeapMemoryWatermarkThresholdspoolUsedHeapMemoryThreshold="70"/>

Then notice that as spoolThreshold is default enabled with 128kb, then we have both thresholds in use (spoolThreads spoolThreshold and spoolHeapMemoryWatermarkThresholdspoolUsedHeapMemoryThreshold). And in this example then we only spool to disk if payload is > 128kb and that used heap memory is > 70%. The reason is that we have the option anySpoolRules as default false. That means both rules must be true (eg AND).

...

Code Block
    <streamCaching id="myCacheConfig" spoolDirectory="/tmp/cachedir" spoolHeapMemoryWatermarkThresholdspoolUsedHeapMemoryThreshold="70" anySpoolRules="true"/>

...

Code Block
    <streamCaching id="myCacheConfig" spoolDirectory="/tmp/cachedir" spoolThreshold="-1" spoolHeapMemoryWatermarkThresholdspoolUsedHeapMemoryThreshold="70"/>

... then we do not use the spoolThreshold rule, and only the heap memory based is in use.

By default the upper limit of the used heap memory is based on the maximum heap size. Though you can also configure to use the committed heap size as the upper limit, this is done using the spoolUsedHeapMemoryThreshold option as shown below:

Code Block

    <streamCaching id="myCacheConfig" spoolDirectory="/tmp/cachedir" spoolUsedHeapMemoryThreshold="70" spoolUsedHeapMemoryLimit="Committed"/>

Using custom SpoolRule implementations

...