Class FileConsumer

java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.support.DefaultConsumer
org.apache.camel.support.ScheduledPollConsumer
org.apache.camel.support.ScheduledBatchPollingConsumer
org.apache.camel.component.file.GenericFileConsumer<File>
org.apache.camel.component.file.FileConsumer
All Implemented Interfaces:
AutoCloseable, Runnable, org.apache.camel.BatchConsumer, org.apache.camel.Consumer, org.apache.camel.EndpointAware, org.apache.camel.health.HealthCheckAware, org.apache.camel.PollingConsumerPollingStrategy, org.apache.camel.resume.ResumeAware<org.apache.camel.resume.ResumeStrategy>, org.apache.camel.RouteAware, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.HostedService, org.apache.camel.spi.RouteIdAware, org.apache.camel.spi.ShutdownAware, org.apache.camel.spi.ShutdownPrepared, org.apache.camel.StatefulService, org.apache.camel.Suspendable, org.apache.camel.SuspendableService

public class FileConsumer extends GenericFileConsumer<File> implements org.apache.camel.resume.ResumeAware<org.apache.camel.resume.ResumeStrategy>
File consumer.
  • Constructor Details

  • Method Details

    • createExchange

      protected org.apache.camel.Exchange createExchange(GenericFile<File> file)
      Description copied from class: GenericFileConsumer
      Creates the exchange from the polled file
      Specified by:
      createExchange in class GenericFileConsumer<File>
    • pollDirectory

      protected boolean pollDirectory(org.apache.camel.Exchange dynamic, String fileName, List<GenericFile<File>> fileList, int depth)
      Description copied from class: GenericFileConsumer
      Polls the given directory for files to process
      Specified by:
      pollDirectory in class GenericFileConsumer<File>
      Parameters:
      fileName - current directory or file
      fileList - current list of files gathered
      depth - the current depth of the directory (will start from 0)
      Returns:
      whether or not to continue polling, false means the maxMessagesPerPoll limit has been hit
    • isMatched

      protected boolean isMatched(Supplier<GenericFile<File>> file, String doneFileName, File[] files)
      Description copied from class: GenericFileConsumer
      Strategy to perform file matching based on endpoint configuration in terms of done file name.
      Specified by:
      isMatched in class GenericFileConsumer<File>
      Parameters:
      file - the file
      doneFileName - the done file name (without any paths)
      files - files in the directory
      Returns:
      true if the file is matched, false if not
    • asGenericFile

      public static GenericFile<File> asGenericFile(String endpointPath, File file, String charset, boolean probeContentType)
      Creates a new GenericFile based on the given file.
      Parameters:
      endpointPath - the starting directory the endpoint was configured with
      file - the source file
      probeContentType - whether to probe the content type of the file or not
      Returns:
      wrapped as a GenericFile
    • getRelativeFilePath

      protected Supplier<String> getRelativeFilePath(String endpointPath, String path, String absolutePath, File file)
      Description copied from class: GenericFileConsumer
      Geta the relative path from the given file, calculated from the starting path, current path, and current absolute path
      Specified by:
      getRelativeFilePath in class GenericFileConsumer<File>
    • updateFileHeaders

      protected void updateFileHeaders(GenericFile<File> file, org.apache.camel.Message message)
      Description copied from class: GenericFileConsumer
      Updates the information on Message after we have acquired read-lock and can begin process the file.
      Specified by:
      updateFileHeaders in class GenericFileConsumer<File>
      Parameters:
      file - the file
      message - the Camel message to update its headers
    • getEndpoint

      public FileEndpoint getEndpoint()
      Specified by:
      getEndpoint in interface org.apache.camel.EndpointAware
      Overrides:
      getEndpoint in class org.apache.camel.support.DefaultConsumer
    • isMatchedHiddenFile

      protected boolean isMatchedHiddenFile(Supplier<GenericFile<File>> file, String name, boolean isDirectory)
      Description copied from class: GenericFileConsumer
      Strategy to perform hidden file matching based on endpoint configuration.

      Will always return false for certain files/folders:

      • Starting with a dot (hidden)
      Overrides:
      isMatchedHiddenFile in class GenericFileConsumer<File>
    • doStart

      protected void doStart() throws Exception
      Overrides:
      doStart in class GenericFileConsumer<File>
      Throws:
      Exception
    • getResumeStrategy

      public org.apache.camel.resume.ResumeStrategy getResumeStrategy()
      Specified by:
      getResumeStrategy in interface org.apache.camel.resume.ResumeAware<org.apache.camel.resume.ResumeStrategy>
    • setResumeStrategy

      public void setResumeStrategy(org.apache.camel.resume.ResumeStrategy resumeStrategy)
      Specified by:
      setResumeStrategy in interface org.apache.camel.resume.ResumeAware<org.apache.camel.resume.ResumeStrategy>
    • adapterFactoryService

      public String adapterFactoryService()
      Specified by:
      adapterFactoryService in interface org.apache.camel.resume.ResumeAware<org.apache.camel.resume.ResumeStrategy>