Stream cachingPage edited by Aki YoshidaChanges (2)
Full ContentStream cachingWhile stream types (like StreamSource, InputStream and Reader) are commonly used in messaging for performance reasons, they also have an important drawback: they can only be read once. In order to be able to work with message content multiple times, the stream needs to be cached. Streams are caching in memory. In Camel 2.0, large stream messages (over 64 Kb) will be cached in a temporary file instead – Camel itself will handle deleting the temporary file once the cached stream is no longer necessary. In Camel 2.0 stream cache is default disabled out of the box.
Enabling stream cachingIn Apache Camel, you can explicitly enable stream caching for a single route with the streamCaching DSL method: from("jbi:service:http://foo.bar.org/MyService") .streamCaching() .to("jbi:service:http://foo.bar.org/MyOtherService");
Streaming cache to filesWhen 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:
You set these properties on the CamelContext as shown below: context.getProperties().put(CachedOutputStream.TEMP_DIR, "/tmp/cachedir"); context.getProperties().put(CachedOutputStream.THRESHOLD, "1024"); context.getProperties().put(CachedOutputStream.BUFFER_SIZE, "4096"); // to enable encryption using RC4 // context.getProperties().put(CachedOutputStream.CIPHER_TRANSFORMATION, "RC4"); Disabling spooling to diskAvailable as of *Camel 1.6.2/2.0 // 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.
Change Notification Preferences
View Online
|
View Changes
|
Add Comment
|
- [CONF] Apache Camel > Stream caching confluence
- [CONF] Apache Camel > Stream caching confluence
- [CONF] Apache Camel > Stream caching confluence
- [CONF] Apache Camel > Stream caching Claus Ibsen (Confluence)
- [CONF] Apache Camel > Stream caching Claus Ibsen (Confluence)
- [CONF] Apache Camel > Stream caching Claus Ibsen (Confluence)
- [CONF] Apache Camel > Stream caching Claus Ibsen (Confluence)
- [CONF] Apache Camel > Stream caching Claus Ibsen (Confluence)
- [CONF] Apache Camel > Stream caching Claus Ibsen (Confluence)
- [CONF] Apache Camel > Stream caching Claus Ibsen (Confluence)
- [CONF] Apache Camel > Stream caching Claus Ibsen (Confluence)