Mule file inbound polling configuration

I want to poll 10 files for a certain period of time from a specific directory. If in this directory there are 250 files included in the Mule file, it should take 10 of 250 files and process them, and then 10 files, etc. I have a polling rate of "10000"

I tried applying maxThreadsActive like this, but it does not work

<file:connector>
<receiver-thread-profile maxThreadsActive=10/>
</file:connector>
+5
source share
1 answer

Mule allows you to override some parts of a transport implementation. In this case, you must override org.mule.transport.file.FileMessageReceiver, in particular, the method listFiles().

public class MyFileMessageReceiver extends FileMessageReceiver
{
    private static final MAX_FILES = 10;

    @Override
    List<File> listFiles() throws MuleException
    {
        try
        {
            List<File> files = new ArrayList<File>();
            this.basicListFiles(readDirectory, files);

            if(files.isEmpty())
                return NO_FILES;

            if(files.size() > MAX_FILES)
                return files.subList(0, MAX_FILES);
            else
                return files;
        }
        catch (Exception e)
        {
            throw new DefaultMuleException(FileMessages.errorWhileListingFiles(), e);
        }
    }
}

Then create a connector that will use the message receiver

<file:connector name="inboundFileConnector"> 
    <service-overrides messageReceiver="org.mule.transport.file.MyFileMessageReceiver"/> 
</file:connector>

, . , .

+12

All Articles