Mule文件入站轮询配置 [英] Mule File Inbound Polling Configuration
问题描述
我想以特定的时间间隔一次从特定目录中轮询10个文件.如果该目录中存在250个文件,则入站的Mule文件应从250个文件中取出10个文件,然后再处理10个文件,依此类推.我的轮询频率值为"10000"
I want to poll 10 files at a time at certain time intervals from a particular directory. If there exists 250 files in that directory Mule file inbound should take 10 files out of 250 and process them then again 10 files etc.. I have polling frequence value "10000"
我试图像这样应用maxThreadsActive,但是它不起作用
I tried to apply maxThreadsActive like this but it doesnt work
<file:connector>
<receiver-thread-profile maxThreadsActive=10/>
</file:connector>
推荐答案
Mule使您可以覆盖传输实现的某些部分.在这种情况下,您应该覆盖org.mule.transport.file.FileMessageReceiver
,尤其是listFiles()
方法.
Mule lets you override certain parts of the transport implementation. In this case you should override org.mule.transport.file.FileMessageReceiver
, specifically listFiles()
method.
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 your message receiver
<file:connector name="inboundFileConnector">
<service-overrides messageReceiver="org.mule.transport.file.MyFileMessageReceiver"/>
</file:connector>
最后,您可以将此连接器与配置中的任何文件入站端点一起使用.您只需要指定轮询频率就可以了.
Finally you can use this connector with any file inbound endpoint in your config. You just have to specify the polling frequency and you're done.
HTH
这篇关于Mule文件入站轮询配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!