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}) public class StreamEndpoint extends org.apache.camel.support.DefaultEndpoint
Read 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.Consumer
createConsumer(org.apache.camel.Processor processor)
org.apache.camel.Producer
createProducer()
protected void
doStart()
int
getAutoCloseCount()
Charset
getCharset()
long
getDelay()
String
getEncoding()
String
getFileName()
int
getGroupLines()
GroupStrategy
getGroupStrategy()
long
getInitialPromptDelay()
String
getKind()
long
getPromptDelay()
String
getPromptMessage()
int
getReadTimeout()
long
getScanStreamDelay()
boolean
isCloseOnDone()
boolean
isFileWatcher()
boolean
isRetry()
boolean
isScanStream()
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
setInitialPromptDelay(long initialPromptDelay)
Initial delay in milliseconds before showing the message prompt.void
setKind(String kind)
Kind of stream to use such as System.in or System.out.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
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, 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.
-
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.
-
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.
-
-