Tim
Tim

Reputation: 1471

Apache Camel file component to use different directories

Is there an option in Apache camel file component to use multiple different directory from where files can be read.

\
  - home
     - level1
        - level2
          - input   (files are within this folder)
  - dir1
     - test 
        - folder1  ( set of files in this folder)
        - folder2  ( set of files in this folder) 

Another option is using dynamic routing, when the folders are under same directory.

But my use case i can't move files to a common directory, i need the input directory structure to be the same and as two different directories.

is there any option like below?

<from uri="file://home/leve1/level2/input,//dir1/test/folder1,//dir1/test/folder2"/>
<to ...

Upvotes: 0

Views: 899

Answers (2)

Greenev
Greenev

Reputation: 909

Another thing to consider here is recursive option which you could use along with antInclude or include options. In this case you will be able to poll different directories with just one consumer, e.g.

<from uri="file://dir1/test?recursive=true&amp;antInclude=folder1/*,folder2/*" />

Note though, this would be very inefficient if you poll recursively too big file trees

Upvotes: 2

hk6279
hk6279

Reputation: 1879

The file component accept 1 path as input (for context path). Instead of multiple paths in single file component, you could consider having multiple file component.

  • Use multiple from EIP and point to same endpoint
<from uri="file://home/leve1/level2/input" />
    <to uri="direct:file-handler" />

<from uri="file://dir1/test/folder1" />
    <to uri="direct:file-handler" />

<from uri="file://dir1/test/folder2" />
    <to uri="direct:file-handler" />

<from uri="direct:file-handler" />
    <!-- your logic goes here -->

Upvotes: 2

Related Questions