The stream: component provides access to the
System.err streams as well as allowing streaming of file and URL.
Maven users will need to add the following dependency to their
pom.xml for this component:
In addition, the
url endpoint URIs are supported:
stream:header URI is specified, the
stream header is used to find the stream to write to. This option is available only for stream producers (that is, it cannot appear in
You can append query options to the URI in the following format,
Initial delay in milliseconds before consuming or producing the stream.
Message prompt to use when reading from
Optional delay in milliseconds before showing the message prompt.
Initial delay in milliseconds before showing the message prompt. This delay occurs only once. Can be used during system startup to avoid message prompts being written while other logging is done to the system out.
When using the
When using the
To be used for continuously reading a stream such as the unix
Camel 2.7: will retry opening the file if it's overwritten, somewhat like
Delay in milliseconds between read attempts when using
Camel 2.10.0: (2.9.3 and 2.8.6) Number of messages to process before closing stream on Producer side. Never close stream by default (only when Producer is stopped). If more messages are sent, the stream is reopened for another
Camel 2.11.0: This option is used in combination with Splitter and streaming to the same file. The idea is to keep the stream open and only close when the Splitter is done, to improve performance. Mind this requires that you only stream to the same file, and not 2 or more files, and that the last split message that carries the information that its the last, is routed to the stream endpoint so it gets the signal to close.
The stream: component supports either
byte for writing to streams. Just add either
byte content to the
message.in.body. Messages sent to the stream: producer in binary mode are not followed by the newline character (as opposed to the
String messages). Message with
null body will not be appended to the output stream.
stream:header URI is used for custom output streams. Just add a
java.io.OutputStream object to
message.in.header in the key
See samples for an example.
In the following sample we route messages from the
direct:in endpoint to the
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,
One gotcha with scanStream (pre Camel 2.7) or scanStream + retry is the file will be re-opened and scanned with each iteration of scanStreamDelay. Until NIO2 is available we cannot reliably detect when a file is deleted/recreated.