Camel: Splitting a collection and writing to files

后端 未结 2 566
滥情空心
滥情空心 2021-02-08 05:55

I´m trying to split an ArrayList and writing each element to it´s own file using Apache Camel like in this simplified example:

from(\"timer://poll?period=10000\"         


        
2条回答
  •  悲&欢浪女
    2021-02-08 06:51

    The file producer will by default "override" if a file already exists.

    See the fileExist option at its documentation page http://camel.apache.org/file2

    Since the input to this route is also a file, then the producer will "inherit" the file name from the input.

    So in your case if you want to save each splitted message in a new file, then you would need to set a target file name, using the fileName option

    "file:some/dir?fileName=splitted-${id}"
    

    The fileName option supports the simple and file language

    http://camel.apache.org/simple.html

    http://camel.apache.org/file-language.html

    That means the file name can be dynamic computed, such as above, where ${id} is an unique message id.

提交回复
热议问题