Camilo Melani
Camilo Melani

Reputation: 31

Delete a file after all the rows in the file have been processed

I would like to delete a file after all the rows in the file have been processed. My streams look like

source (file --fixedDelay=0 --outputType=text/plain --dir=XXX) | 
    splitter --expression=payload.split('\\n') | 
    transform -> filter -> sink

My files are stored in a directory, that is being watched by the file module. I would like that each file is deleted after it has been processed.

Thanks.

Upvotes: 3

Views: 209

Answers (1)

user152468
user152468

Reputation: 3242

Indeed it is surprising that the file source does not have an option for deleting the file after processing, which can be confirmed by looking at the configuration file in xd/modules/source/file/config/file.xml (as of version 1.1.0).

While the file source does not have this option, the sftp source does have it. Hence you could use the sftp source. This will require an ssh server on the machine where spring xd is installed. Does this help?

You may also want to add your own custom source module by configuring a file transformer. File transformers support a delete-files="true" option:

http://docs.spring.io/spring-integration/reference/html/files.html

Upvotes: 1

Related Questions