...
The stream: component provides access to the System.in
, System.out
and System.err
streams together with as well as allowing streaming of file and urlURL.
URI format
Code Block |
---|
stream:in[?options] stream:out[?options] stream:err[?options] stream:header[?options] |
And In addition, the file
and url
is endpoint URIs are supported in Camel 2.0:
Code Block |
---|
stream:file?fileName=/foo/bar.txt stream:url [?options] |
If the stream:header
option URI is specified then , the stream
header is used to find the stream to write to. This option is available only available for StreamProducerfor stream producers (that is, it cannot appear in from()
).
You can append query options to the URI in the following format, ?option=value&option=value&...
Options
Name | Default Value | Description |
---|---|---|
| | Initial delay in millis milliseconds before consuming or producing the stream. |
| JVM Default | As of 1.4 or later , you can configure the encoding (is a charset name) to use text-based streams (eg. for example, message body is a |
| | Camel 2.0: Leading prompt message that can be used Message prompt to use when reading from |
| | Camel 2.0: Optional delay in millis milliseconds before showing the message prompt message. Can be used when during system startup to avoid prompt message prompts being written while other logging is done to the System system out. |
| | Camel 2.0: Optional delay in millis milliseconds before showing the message prompt message. |
| | Camel 2.0: initial Initial delay in millis milliseconds before showing the message prompt message. This delay occurs only occurs once. Can be used when during system startup to avoid prompt message prompts being written while other logging is done to the System system out. |
| | Camel 2.0: When using the |
| | Camel 2.0: To be used for continuously reading a stream such as the unit |
| | Camel 2.0: Delay in millis milliseconds between read attempts when using |
Message content
The stream: component supports either String
or byte[]
for writing to streams. Just add either String
or byte[]
content to the message.in.body
either a Stirng or byte[] content.
The special stream:header
URI is used for custom output streams. Just add a java.io.OutputStream
object to message.in.header
in the key header
.
See samples for an example.
Samples
In this the following sample we output to System.out the content route messages from the message when its put on the direct:in
queue. endpoint to the System.out
stream:
Wiki Markup |
---|
{snippet:id=e1|lang=java|url=camel/trunk/components/camel-stream/src/test/java/org/apache/camel/component/stream/StreamSystemOutTest.java} |
This The following sample demonstrates how the header type can be used to determine which stream to use. In the sample we use our own output stream (, MyOutputStream
).
Wiki Markup |
---|
{snippet:id=e1|lang=java|url=camel/trunk/components/camel-stream/src/test/java/org/apache/camel/component/stream/StreamHeaderTest.java} |
This The following sample demonstrates how to continously continuously read a file stream such as the Unix (analogous to the UNIX tail
command):
Code Block | ||||
---|---|---|---|---|
| ||||
from("stream:file?fileName=/server/logs/server.log?scanStream=true&scanStreamDelay=1000").to("bean:logService?method=parseLogLine"); |
...