2 Home
gitea_admin edited this page 2026-03-11 14:42:41 +00:00

Stream

Read from system-in and write to system-out and system-err streams.

Metadata

Property Value
Scheme stream
Support Level Stable
Labels file,core
Version 4.10.2

Maven Dependency

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-stream</artifactId>
    <version>4.10.2</version>
</dependency>

Endpoint Properties

Name Type Required Default Description
kind string Kind of stream to use such as System.in, System.out, a file, or a http url.
encoding string You can configure the encoding (is a charset name) to use text-based streams (for example, message body is a String object). If not provided, Camel uses the JVM default Charset.
fileName string When using the stream:file URI format, this option specifies the filename to stream to/from.
fileWatcher boolean false To use JVM file watcher to listen for file change events to support re-loading files that may be overwritten, somewhat like tail --retry
groupLines integer To group X number of lines in the consumer. For example to group 10 lines and therefore only spit out an Exchange with 10 lines, instead of 1 Exchange per line.
groupStrategy object Allows to use a custom GroupStrategy to control how to group lines.
httpHeaders string When using stream:http format, this option specifies optional http headers, such as Accept: application/json. Multiple headers can be separated by comma. The format of headers can be either HEADER=VALUE or HEADER:VALUE. In accordance with the HTTP/1.1 specification, leading and/or trailing whitespace is ignored
httpUrl string When using stream:http format, this option specifies the http url to stream from.
initialPromptDelay integer 2000 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.
promptDelay integer Optional delay in milliseconds before showing the message prompt.
promptMessage string Message prompt to use when reading from stream:in; for example, you could set this to Enter a command:
readLine boolean true Whether to read the input stream in line mode (terminate by line breaks). Setting this to false, will instead read the entire stream until EOL.
retry boolean false Will retry opening the stream if it's overwritten, somewhat like tail --retry If reading from files then you should also enable the fileWatcher option, to make it work reliable.
scanStream boolean false To be used for continuously reading a stream such as the unix tail command.
scanStreamDelay integer Delay in milliseconds between read attempts when using scanStream.
bridgeErrorHandler boolean false Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored.
exceptionHandler object To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored.
exchangePattern object Sets the exchange pattern when the consumer creates an exchange.
appendNewLine boolean true Whether to append a new line character at end of output.
autoCloseCount integer 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 autoCloseCount batch.
closeOnDone boolean false 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.
delay integer Initial delay in milliseconds before producing the stream.
lazyStartProducer boolean false Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.
readTimeout integer Sets the read timeout to a specified timeout, in milliseconds. A non-zero value specifies the timeout when reading from Input stream when a connection is established to a resource. If the timeout expires before there is data available for read, a java.net.SocketTimeoutException is raised. A timeout of zero is interpreted as an infinite timeout.