Class FileReadingMessageSource

java.lang.Object
org.springframework.integration.util.AbstractExpressionEvaluator
org.springframework.integration.endpoint.AbstractMessageSource<File>
org.springframework.integration.file.inbound.FileReadingMessageSource
org.springframework.integration.file.FileReadingMessageSource
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.context.Lifecycle, org.springframework.integration.core.MessageSource<File>, org.springframework.integration.IntegrationPattern, org.springframework.integration.support.context.NamedComponent, org.springframework.integration.support.management.IntegrationInboundManagement, org.springframework.integration.support.management.IntegrationManagement, org.springframework.integration.support.management.ManageableLifecycle

@Deprecated(forRemoval=true, since="7.0") public class FileReadingMessageSource extends FileReadingMessageSource
Deprecated, for removal: This API element is subject to removal in a future version.
since 7.0 in favor FileReadingMessageSource
MessageSource that creates messages from a file system directory. To prevent messages for certain files, you may supply a FileListFilter. By default, when configuring with XML or the DSL, an AcceptOnceFileListFilter is used. It ensures files are picked up only once from the directory.

A common problem with reading files is that a file may be detected before it is ready. The default AcceptOnceFileListFilter does not prevent this. In most cases, this can be prevented if the file-writing process renames each file as soon as it is ready for reading. A pattern-matching filter that accepts only files that are ready (e.g. based on a known suffix), composed with the default AcceptOnceFileListFilter would allow for this.

If a external DirectoryScanner is used, then the FileLocker and FileListFilter objects should be set on the external DirectoryScanner, not the instance of FileReadingMessageSource. An IllegalStateException will result otherwise.

A Comparator can be used to ensure internal ordering of the Files in a PriorityBlockingQueue. This does not provide the same guarantees as a ResequencingMessageGroupProcessor, but in cases where writing files and failure downstream are rare it might be sufficient.

FileReadingMessageSource is fully thread-safe under concurrent receive() invocations and message delivery callbacks.

  • Nested Class Summary

    Nested classes/interfaces inherited from class FileReadingMessageSource

    FileReadingMessageSource.WatchEventType

    Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement

    org.springframework.integration.support.management.IntegrationManagement.ManagementOverrides
  • Field Summary

    Fields inherited from class org.springframework.integration.util.AbstractExpressionEvaluator

    EXPRESSION_PARSER, logger

    Fields inherited from interface org.springframework.integration.support.management.IntegrationManagement

    METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated, for removal: This API element is subject to removal in a future version.
    Create a FileReadingMessageSource with a naturally ordered queue of unbounded capacity.
    FileReadingMessageSource(int internalQueueCapacity)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Create a FileReadingMessageSource with a bounded queue of the given capacity.
    FileReadingMessageSource(@Nullable Comparator<File> receptionOrderComparator)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Create a FileReadingMessageSource with a PriorityBlockingQueue ordered with the passed in Comparator.
  • Method Summary

    Methods inherited from class org.springframework.integration.endpoint.AbstractMessageSource

    buildMessage, destroy, getComponentName, getManagedName, getManagedType, getOverrides, isLoggingEnabled, receive, registerMetricsCaptor, setBeanName, setHeaderExpressions, setLoggingEnabled, setManagedName, setManagedType

    Methods inherited from class org.springframework.integration.util.AbstractExpressionEvaluator

    afterPropertiesSet, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, getBeanFactory, getEvaluationContext, getEvaluationContext, getMessageBuilderFactory, setBeanFactory, setConversionService, setSimpleEvaluationContext

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.integration.support.management.IntegrationManagement

    getThisAs, isObserved, registerObservationRegistry

    Methods inherited from interface org.springframework.integration.core.MessageSource

    getIntegrationPatternType

    Methods inherited from interface org.springframework.integration.support.context.NamedComponent

    getBeanName
  • Constructor Details

    • FileReadingMessageSource

      public FileReadingMessageSource()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Create a FileReadingMessageSource with a naturally ordered queue of unbounded capacity.
    • FileReadingMessageSource

      public FileReadingMessageSource(int internalQueueCapacity)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Create a FileReadingMessageSource with a bounded queue of the given capacity. This can be used to reduce the memory footprint of this component when reading from a large directory.
      Parameters:
      internalQueueCapacity - the size of the queue used to cache files to be received internally. This queue can be made larger to optimize the directory scanning. With scanEachPoll set to false and the queue to a large size, it will be filled once and then completely emptied before a new directory listing is done. This is particularly useful to reduce scans of large numbers of files in a directory.
    • FileReadingMessageSource

      public FileReadingMessageSource(@Nullable Comparator<File> receptionOrderComparator)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Create a FileReadingMessageSource with a PriorityBlockingQueue ordered with the passed in Comparator.

      The size of the queue used should be large enough to hold all the files in the input directory in order to sort all of them, so restricting the size of the queue is mutually exclusive with ordering. No guarantees about file delivery order can be made under concurrent access.

      Parameters:
      receptionOrderComparator - the comparator to be used to order the files in the internal queue