Class StreamEndpoint
java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.support.DefaultEndpoint
org.apache.camel.component.stream.StreamEndpoint
- All Implemented Interfaces:
AutoCloseable
,org.apache.camel.CamelContextAware
,org.apache.camel.ComponentAware
,org.apache.camel.Endpoint
,org.apache.camel.IsSingleton
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.spi.HasCamelContext
,org.apache.camel.spi.HasId
,org.apache.camel.StatefulService
,org.apache.camel.SuspendableService
@UriEndpoint(firstVersion="1.3.0",
scheme="stream",
title="Stream",
syntax="stream:kind",
category={FILE,CORE},
headersClass=StreamConstants.class)
public class StreamEndpoint
extends org.apache.camel.support.DefaultEndpoint
Read from system-in and write to system-out and system-err streams.
-
Field Summary
Fields inherited from class org.apache.camel.support.service.BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.camel.Consumer
createConsumer
(org.apache.camel.Processor processor) org.apache.camel.Producer
protected void
doStart()
int
long
getDelay()
int
long
getKind()
long
int
long
boolean
boolean
boolean
boolean
boolean
isRetry()
boolean
void
setAppendNewLine
(boolean appendNewLine) Whether to append a new line character at end of output.void
setAutoCloseCount
(int autoCloseCount) Number of messages to process before closing stream on Producer side.void
setCloseOnDone
(boolean closeOnDone) This option is used in combination with Splitter and streaming to the same file.void
setDelay
(long delay) Initial delay in milliseconds before producing the stream.void
setEncoding
(String encoding) You can configure the encoding (is a charset name) to use text-based streams (for example, message body is a String object).void
setFileName
(String fileName) When using the stream:file URI format, this option specifies the filename to stream to/from.void
setFileWatcher
(boolean fileWatcher) To use JVM file watcher to listen for file change events to support re-loading files that may be overwritten, somewhat like tail --retryvoid
setGroupLines
(int groupLines) To group X number of lines in the consumer.void
setGroupStrategy
(GroupStrategy strategy) Allows to use a custom GroupStrategy to control how to group lines.void
setHttpHeaders
(String httpHeaders) When using stream:http format, this option specifies optional http headers, such as Accept: application/json.void
setHttpUrl
(String httpUrl) When using stream:http format, this option specifies the http url to stream from.void
setInitialPromptDelay
(long initialPromptDelay) Initial delay in milliseconds before showing the message prompt.void
Kind of stream to use such as System.in, System.out, a file, or a http url.void
setPromptDelay
(long promptDelay) Optional delay in milliseconds before showing the message prompt.void
setPromptMessage
(String promptMessage) Message prompt to use when reading from stream:in; for example, you could set this to Enter a command:void
setReadLine
(boolean readLine) Whether to read the input stream in line mode (terminate by line breaks).void
setReadTimeout
(int readTimeout) Sets the read timeout to a specified timeout, in milliseconds.void
setRetry
(boolean retry) Will retry opening the stream if it's overwritten, somewhat like tail --retryvoid
setScanStream
(boolean scanStream) To be used for continuously reading a stream such as the unix tail command.void
setScanStreamDelay
(long scanStreamDelay) Delay in milliseconds between read attempts when using scanStream.Methods inherited from class org.apache.camel.support.DefaultEndpoint
configureConsumer, configureExchange, configurePollingConsumer, configureProperties, createAsyncProducer, createEndpointUri, createExchange, createExchange, createPollingConsumer, doInit, equals, getCamelContext, getComponent, getEndpointKey, getEndpointUri, getExceptionHandler, getExchangePattern, getId, getPollingConsumerBlockTimeout, getPollingConsumerQueueSize, hashCode, isAutowiredEnabled, isBridgeErrorHandler, isLazyStartProducer, isLenientProperties, isPollingConsumerBlockWhenFull, isPollingConsumerCopy, isSingleton, setAutowiredEnabled, setBridgeErrorHandler, setCamelContext, setComponent, setEndpointUri, setEndpointUriIfNotSpecified, setExceptionHandler, setExchangePattern, setLazyStartProducer, setPollingConsumerBlockTimeout, setPollingConsumerBlockWhenFull, setPollingConsumerCopy, setPollingConsumerQueueSize, setProperties, toString
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doStop, doSuspend, fail, getInternalLock, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.camel.ComponentAware
getComponent
Methods inherited from interface org.apache.camel.Endpoint
getEndpointBaseUri, isRemote, isSingletonProducer
Methods inherited from interface org.apache.camel.Service
build, close, init, start, stop
Methods inherited from interface org.apache.camel.ShutdownableService
shutdown
Methods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending
Methods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Constructor Details
-
StreamEndpoint
- Throws:
Exception
-
-
Method Details
-
createConsumer
public org.apache.camel.Consumer createConsumer(org.apache.camel.Processor processor) throws Exception - Throws:
Exception
-
createProducer
- Throws:
Exception
-
getKind
-
setKind
Kind of stream to use such as System.in, System.out, a file, or a http url. -
getFileName
-
setFileName
When using the stream:file URI format, this option specifies the filename to stream to/from. -
getHttpUrl
-
setHttpUrl
When using stream:http format, this option specifies the http url to stream from. -
getHttpHeaders
-
setHttpHeaders
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 -
getDelay
public long getDelay() -
setDelay
public void setDelay(long delay) Initial delay in milliseconds before producing the stream. -
getEncoding
-
setEncoding
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. -
getPromptMessage
-
setPromptMessage
Message prompt to use when reading from stream:in; for example, you could set this to Enter a command: -
getPromptDelay
public long getPromptDelay() -
setPromptDelay
public void setPromptDelay(long promptDelay) Optional delay in milliseconds before showing the message prompt. -
getInitialPromptDelay
public long getInitialPromptDelay() -
setInitialPromptDelay
public void setInitialPromptDelay(long initialPromptDelay) 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. -
isScanStream
public boolean isScanStream() -
setScanStream
public void setScanStream(boolean scanStream) To be used for continuously reading a stream such as the unix tail command. -
getGroupStrategy
-
setGroupStrategy
Allows to use a custom GroupStrategy to control how to group lines. -
isRetry
public boolean isRetry() -
setRetry
public void setRetry(boolean retry) 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. -
isFileWatcher
public boolean isFileWatcher() -
setFileWatcher
public void setFileWatcher(boolean fileWatcher) To use JVM file watcher to listen for file change events to support re-loading files that may be overwritten, somewhat like tail --retry -
isCloseOnDone
public boolean isCloseOnDone() -
setCloseOnDone
public void setCloseOnDone(boolean closeOnDone) 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. -
getScanStreamDelay
public long getScanStreamDelay() -
setScanStreamDelay
public void setScanStreamDelay(long scanStreamDelay) Delay in milliseconds between read attempts when using scanStream. -
getGroupLines
public int getGroupLines() -
setGroupLines
public void setGroupLines(int groupLines) 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. -
isReadLine
public boolean isReadLine() -
setReadLine
public void setReadLine(boolean readLine) 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. -
getAutoCloseCount
public int getAutoCloseCount() -
setAutoCloseCount
public void setAutoCloseCount(int autoCloseCount) 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. -
isAppendNewLine
public boolean isAppendNewLine() -
setAppendNewLine
public void setAppendNewLine(boolean appendNewLine) Whether to append a new line character at end of output. -
getCharset
-
getReadTimeout
public int getReadTimeout() -
setReadTimeout
public void setReadTimeout(int readTimeout) 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. -
doStart
- Overrides:
doStart
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-