springintegrationspring-integrationinboundpoller

Reading of files with max-messages-per-poll=10 and prevent-duplicates=false


I'm trying to read files from the directory. If file cannot be processed it stays there to be tried later.

<file:inbound-channel-adapter prevent-duplicates="false" id="fileInput" directory="file:${java.io.dir}/input-data" auto-create-directory="true" filter="compositeFileFilterBean"/>

    <integration:poller id="poller" max-messages-per-poll="10" default="true" >
        <integration:interval-trigger interval="60" time-unit="SECONDS" />
    </integration:poller>

The problem is if max-messages-per-poll set to, say 10, then each poll will return exactly 10 messages, even if there is only 1 file (i.e. all 10 messages will be the same).


Solution

  • Yes, that would be the expected behavior with those settings.

    I am not sure why you think that is wrong.

    If there is a file in the directory that is not filtered by a filter (such as the one that prevents duplicates), it will be found by the poller, either within the current poll (when max-messages-per-poll is > 1) or on the next poll.

    To do what you want, you would need a custom filter, that would filter a file that was previously found within your 60 seconds polling interval.