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.ConsumercreateConsumer(org.apache.camel.Processor processor) org.apache.camel.Producerprotected voiddoStart()intlonggetDelay()intlonggetKind()longintlongbooleanbooleanbooleanbooleanbooleanisRetry()booleanvoidsetAppendNewLine(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.voidsetHttpHeaders(String httpHeaders) When using stream:http format, this option specifies optional http headers, such as Accept: application/json.voidsetHttpUrl(String httpUrl) When using stream:http format, this option specifies the http url to stream from.voidsetInitialPromptDelay(long initialPromptDelay) Initial delay in milliseconds before showing the message prompt.voidKind of stream to use such as System.in, System.out, a file, or a http url.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, 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, toStringMethods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doStop, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.camel.ComponentAware
getComponentMethods inherited from interface org.apache.camel.Endpoint
getEndpointBaseUri, isSingletonProducerMethods inherited from interface org.apache.camel.Service
build, close, init, start, stopMethods inherited from interface org.apache.camel.ShutdownableService
shutdownMethods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods 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. -
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:
doStartin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-