Class FileSplitter
- All Implemented Interfaces:
- org.reactivestreams.Subscriber<Message<?>>,- Aware,- BeanClassLoaderAware,- BeanFactoryAware,- BeanNameAware,- DisposableBean,- InitializingBean,- ApplicationContextAware,- Ordered,- ComponentSourceAware,- ExpressionCapable,- Orderable,- MessageProducer,- DiscardingMessageHandler,- HeaderPropagationAware,- IntegrationPattern,- NamedComponent,- IntegrationManagement,- TrackableComponent,- MessageHandler,- reactor.core.CoreSubscriber<Message<?>>
AbstractMessageSplitter implementation to split the File Message
 payload to lines.
 
 With iterator = true (defaults to true) this class produces an
 Iterator to process file lines on demand from Iterator.next(). Otherwise
 a List of all lines is returned to the to further
 AbstractMessageSplitter.handleRequestMessage(org.springframework.messaging.Message<?>) process.
 
 Can accept String as file path, File, Reader or
 InputStream as payload type. All other types are ignored and returned to the
 AbstractMessageSplitter as is.
 
 If setFirstLineAsHeader(String) is specified, the first line of the content is
 treated as a header and carried as a header with the provided name in the messages
 emitted for the remaining lines. In this case, if markers are enabled, the line count
 in the END marker does not include the header line and, if
 applySequence is true, the header is not included in
 the sequence.
- Since:
- 4.1.2
- Author:
- Artem Bilan, Gary Russell, Ruslan Stelmachenko
- 
Nested Class SummaryNested ClassesNested classes/interfaces inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandlerAbstractReplyProducingMessageHandler.RequestHandlerNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagementIntegrationManagement.ManagementOverrides
- 
Field SummaryFields inherited from class org.springframework.integration.handler.AbstractMessageProducingHandlermessagingTemplateFields inherited from class org.springframework.integration.context.IntegrationObjectSupportEXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagementMETER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.core.OrderedHIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
- 
Constructor SummaryConstructorsConstructorDescriptionConstruct a splitter where thesplitMessage(Message)method returns an iterator and the file is read line-by-line during iteration.FileSplitter(boolean iterator) Construct a splitter where thesplitMessage(Message)method returns an iterator, and the file is read line-by-line during iteration, or a list of lines from the file.FileSplitter(boolean iterator, boolean markers) Construct a splitter where thesplitMessage(Message)method returns an iterator, and the file is read line-by-line during iteration, or a list of lines from the file.FileSplitter(boolean iterator, boolean markers, boolean markersJson) Construct a splitter where thesplitMessage(Message)method returns an iterator, and the file is read line-by-line during iteration, or a list of lines from the file.
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidaddHeaders(Message<?> message, Map<String, Object> headers) Allows subclasses to add extra headers to the output messages.voidsetCharset(@Nullable Charset charset) Set the charset to be used when reading the file, when something other than the default charset is required.voidsetFirstLineAsHeader(String firstLineHeaderName) Specify the header name for the first line to be carried as a header in the messages emitted for the remaining lines.protected ObjectsplitMessage(Message<?> message) Subclasses must override this method to split the received Message.protected booleanwillAddHeaders(Message<?> message) Return true if the subclass needs to add headers in the resulting splits.Methods inherited from class org.springframework.integration.splitter.AbstractMessageSplitterdoInit, getComponentType, getDiscardChannel, getIntegrationPatternType, handleRequestMessage, obtainSizeIfPossible, obtainSizeIfPossible, produceOutput, setApplySequence, setDiscardChannel, setDiscardChannelName, shouldCopyRequestHeadersMethods inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandlerdoInvokeAdvisedRequestHandler, getBeanClassLoader, getRequiresReply, handleMessageInternal, hasAdviceChain, onInit, setAdviceChain, setBeanClassLoader, setRequiresReplyMethods inherited from class org.springframework.integration.handler.AbstractMessageProducingHandleraddNotPropagatedHeaders, createOutputMessage, getNotPropagatedHeaders, getOutputChannel, isAsync, messageBuilderForReply, resolveErrorChannel, sendErrorMessage, sendOutput, sendOutputs, setAsync, setNotPropagatedHeaders, setOutputChannel, setOutputChannelName, setSendTimeout, setupMessageProcessor, shouldSplitOutput, updateNotPropagatedHeadersMethods inherited from class org.springframework.integration.handler.AbstractMessageHandlerhandleMessage, onComplete, onError, onNext, onSubscribe, setObservationConventionMethods inherited from class org.springframework.integration.handler.MessageHandlerSupportbuildSendTimer, destroy, getManagedName, getManagedType, getMetricsCaptor, getObservationRegistry, getOrder, getOverrides, isLoggingEnabled, isObserved, registerMetricsCaptor, registerObservationRegistry, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrackMethods inherited from class org.springframework.integration.context.IntegrationObjectSupportafterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentDescription, getComponentName, getComponentSource, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentDescription, setComponentName, setComponentSource, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface reactor.core.CoreSubscribercurrentContextMethods inherited from interface org.springframework.integration.support.management.IntegrationManagementgetThisAsMethods inherited from interface org.springframework.messaging.MessageHandlerhandleMessageMethods inherited from interface org.springframework.integration.support.context.NamedComponentgetBeanName, getComponentName
- 
Constructor Details- 
FileSplitterpublic FileSplitter()Construct a splitter where thesplitMessage(Message)method returns an iterator and the file is read line-by-line during iteration.
- 
FileSplitterpublic FileSplitter(boolean iterator) Construct a splitter where thesplitMessage(Message)method returns an iterator, and the file is read line-by-line during iteration, or a list of lines from the file.- Parameters:
- iterator- true to return an iterator, false to return a list of lines.
 
- 
FileSplitterpublic FileSplitter(boolean iterator, boolean markers) Construct a splitter where thesplitMessage(Message)method returns an iterator, and the file is read line-by-line during iteration, or a list of lines from the file. When file markers are enabled (START/END)applySequenceis false by default. If enabled, the markers are included in the sequence size.- Parameters:
- iterator- true to return an iterator, false to return a list of lines.
- markers- true to emit start of file/end of file marker messages before/after the data.
- Since:
- 4.1.5
 
- 
FileSplitterpublic FileSplitter(boolean iterator, boolean markers, boolean markersJson) Construct a splitter where thesplitMessage(Message)method returns an iterator, and the file is read line-by-line during iteration, or a list of lines from the file. When file markers are enabled (START/END)applySequenceis false by default. If enabled, the markers are included in the sequence size.- Parameters:
- iterator- true to return an iterator, false to return a list of lines.
- markers- true to emit start of file/end of file marker messages before/after the data.
- markersJson- when true, markers are represented as JSON.
- Since:
- 4.2.7
 
 
- 
- 
Method Details- 
setCharsetSet the charset to be used when reading the file, when something other than the default charset is required.- Parameters:
- charset- the charset.
 
- 
setFirstLineAsHeaderSpecify the header name for the first line to be carried as a header in the messages emitted for the remaining lines.- Parameters:
- firstLineHeaderName- the header name to carry first line.
- Since:
- 5.0
 
- 
splitMessageDescription copied from class:AbstractMessageSplitterSubclasses must override this method to split the received Message. The return value may be a Collection or Array. The individual elements may be Messages, but it is not necessary. If the elements are not Messages, each will be provided as the payload of a Message. It is also acceptable to return a single Object or Message. In that case, a single reply Message will be produced.- Specified by:
- splitMessagein class- AbstractMessageSplitter
- Parameters:
- message- The message.
- Returns:
- The result of splitting the message.
 
- 
willAddHeadersDescription copied from class:AbstractMessageSplitterReturn true if the subclass needs to add headers in the resulting splits. If true,AbstractMessageSplitter.addHeaders(org.springframework.messaging.Message<?>, java.util.Map<java.lang.String, java.lang.Object>)will be called.- Overrides:
- willAddHeadersin class- AbstractMessageSplitter
- Parameters:
- message- the message.
- Returns:
- true
 
- 
addHeadersDescription copied from class:AbstractMessageSplitterAllows subclasses to add extra headers to the output messages. Headers may not be removed by this method.- Overrides:
- addHeadersin class- AbstractMessageSplitter
- Parameters:
- message- the inbound message.
- headers- the headers to add messages to.
 
 
-