Poonam Waikul
Poonam Waikul

Reputation: 151

file:inbound-channel-adapter prevent-duplicates="false" is not working in spring boot application

My application is a Spring Boot application. I have a directory named abc. I have created an inbound adapter to read the directory for new files. Let's assume a file aa.txt present in the directory. It is being picked up by the adapter. Now, let's say, again a new file with the same name has been saved in the directory. But, now the adapter does not get invoked.

<file:inbound-channel-adapter id="inAdapter"
    directory="file:abc" filter="txtFiles"
    auto-startup="true" prevent-duplicates="false">
    <int:poller id="poller" fixed-delay="5000" />
</file:inbound-channel-adapter>

I have set prevent-duplicates=false. Still, that file is not getting picked up. Why does this happen? What is the solution?

Upvotes: 1

Views: 864

Answers (2)

Poonam Waikul
Poonam Waikul

Reputation: 151

I got the solution. I have set prevent-duplicates=false to the filter bean(FileListFilterFactoryBean), instead of inbound-channel-adapter & it worked.

Upvotes: 1

Gary Russell
Gary Russell

Reputation: 174739

The default AcceptOnceFileListFilter does not look at the lastModified file attribute, just the file name.

The FileSystemPersistentAcceptOnceFileListFilter compares the timestamp so will pass a modified file with the same name.

See the documentation.

The AcceptOnceFileListFilter stores its state in memory. If you wish the state to survive a system restart, consider using the FileSystemPersistentAcceptOnceFileListFilter instead. This filter stores the accepted file names in a MetadataStore implementation (Section 9.5, “Metadata Store”). This filter matches on the filename and modified time.

Upvotes: 0

Related Questions