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.Endpoint,org.apache.camel.IsSingleton,org.apache.camel.Service,org.apache.camel.ShutdownableService,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,SYSTEM}, headersClass=StreamConstants.class) public class StreamEndpoint extends org.apache.camel.support.DefaultEndpointRead from system-in and write to system-out and system-err streams.
-
-
Constructor Summary
Constructors Constructor Description StreamEndpoint(String endpointUri, org.apache.camel.Component component)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.camel.ConsumercreateConsumer(org.apache.camel.Processor processor)org.apache.camel.ProducercreateProducer()protected voiddoStart()intgetAutoCloseCount()CharsetgetCharset()longgetDelay()StringgetEncoding()StringgetFileName()intgetGroupLines()GroupStrategygetGroupStrategy()longgetInitialPromptDelay()StringgetKind()longgetPromptDelay()StringgetPromptMessage()intgetReadTimeout()longgetScanStreamDelay()booleanisAppendNewLine()booleanisCloseOnDone()booleanisFileWatcher()booleanisReadLine()booleanisRetry()booleanisScanStream()voidsetAppendNewLine(boolean appendNewLine)Whether to append a new line character at end of output.voidsetAutoCloseCount(int autoCloseCount)Number of messages to process before closing stream on Producer side.voidsetCloseOnDone(boolean closeOnDone)This option is used in combination with Splitter and streaming to the same file.voidsetDelay(long delay)Initial delay in milliseconds before producing the stream.voidsetEncoding(String encoding)You can configure the encoding (is a charset name) to use text-based streams (for example, message body is a String object).voidsetFileName(String fileName)When using the stream:file URI format, this option specifies the filename to stream to/from.voidsetFileWatcher(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 --retryvoidsetGroupLines(int groupLines)To group X number of lines in the consumer.voidsetGroupStrategy(GroupStrategy strategy)Allows to use a custom GroupStrategy to control how to group lines.voidsetInitialPromptDelay(long initialPromptDelay)Initial delay in milliseconds before showing the message prompt.voidsetKind(String kind)Kind of stream to use such as System.in or System.out.voidsetPromptDelay(long promptDelay)Optional delay in milliseconds before showing the message prompt.voidsetPromptMessage(String promptMessage)Message prompt to use when reading from stream:in; for example, you could set this to Enter a command:voidsetReadLine(boolean readLine)Whether to read the input stream in line mode (terminate by line breaks).voidsetReadTimeout(int readTimeout)Sets the read timeout to a specified timeout, in milliseconds.voidsetRetry(boolean retry)Will retry opening the stream if it's overwritten, somewhat like tail --retryvoidsetScanStream(boolean scanStream)To be used for continuously reading a stream such as the unix tail command.voidsetScanStreamDelay(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, doStop, 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, doSuspend, fail, 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
-
-
-
-
Method Detail
-
createConsumer
public org.apache.camel.Consumer createConsumer(org.apache.camel.Processor processor) throws Exception- Throws:
Exception
-
getKind
public String getKind()
-
setKind
public void setKind(String kind)
Kind of stream to use such as System.in or System.out.
-
getFileName
public String getFileName()
-
setFileName
public void setFileName(String fileName)
When using the stream:file URI format, this option specifies the filename to stream to/from.
-
getDelay
public long getDelay()
-
setDelay
public void setDelay(long delay)
Initial delay in milliseconds before producing the stream.
-
getEncoding
public String getEncoding()
-
setEncoding
public 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). If not provided, Camel uses the JVM default Charset.
-
getPromptMessage
public String getPromptMessage()
-
setPromptMessage
public void setPromptMessage(String promptMessage)
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
public GroupStrategy getGroupStrategy()
-
setGroupStrategy
public void setGroupStrategy(GroupStrategy strategy)
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
public Charset 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.
-
-