Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dynamic input/output folder location in Camel's file component

As per https://camel.apache.org/file2.html, file component cannot be configured with dynamic input/output folder locations?

Is there any workaround/alternative for the same?

Thanks.

Regards Senthil Kumar Sekar

like image 364
Senthil Kumar Sekar Avatar asked Oct 01 '22 08:10

Senthil Kumar Sekar


2 Answers

For the file consumer

You can use a customer filter as dynamic selection of which directories/files to pickup. But the starting directory is configured once (hardcoded).

For that to change you would need to stop the route, and change the directory, and start the route again - if you want to attempt that direction.

For the file producer

The file name is fully dynamic you can just set a name as the file header you want. See documentation for details.

like image 104
Claus Ibsen Avatar answered Oct 13 '22 11:10

Claus Ibsen


You can use the header CamelFileName also to dynamically set a directory. Slashes will be turned into directories.

Example: CamelFileName = "directory/dyn_subdirectory_n/myfilename.txt" will be placed into the directory "dyn_subdirectory_n" located in "directory". The filename will be "myfilename.txt".

like image 30
moritz.vieli Avatar answered Oct 13 '22 11:10

moritz.vieli