Class FileSplitter

All Implemented Interfaces:
org.reactivestreams.Subscriber<Message<?>>, Aware, BeanClassLoaderAware, BeanFactoryAware, BeanNameAware, DisposableBean, InitializingBean, ApplicationContextAware, Ordered, ExpressionCapable, Orderable, MessageProducer, DiscardingMessageHandler, HeaderPropagationAware, IntegrationPattern, NamedComponent, IntegrationManagement, TrackableComponent, MessageHandler, reactor.core.CoreSubscriber<Message<?>>

public class FileSplitter
extends AbstractMessageSplitter
The 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
  • Constructor Details

    • FileSplitter

      public FileSplitter()
      Construct a splitter where the splitMessage(Message) method returns an iterator and the file is read line-by-line during iteration.
    • FileSplitter

      public FileSplitter​(boolean iterator)
      Construct a splitter where the splitMessage(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.
    • FileSplitter

      public FileSplitter​(boolean iterator, boolean markers)
      Construct a splitter where the splitMessage(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) applySequence is 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
    • FileSplitter

      public FileSplitter​(boolean iterator, boolean markers, boolean markersJson)
      Construct a splitter where the splitMessage(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) applySequence is 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