首页 文章

Spring Integration - 按组进行并行文件处理

提问于
浏览
0

我试图通过一个简单的任务使用Spring Integration实验 . 我有一个文件夹,我收到传入的文件 . 文件以组ID命名 . 我希望按顺序处理同一groupId中的所有文件,但可以并行处理具有不同groupId的文件 .

我开始整理这样的配置:

<int:service-activator input-channel="filesInChannel"
    output-channel="outputChannelAdapter">
    <bean class="com.ingestion.FileProcessor" />
</int:service-activator>

<int:channel id="filesInChannel" />

<int-file:inbound-channel-adapter id="inputChannelAdapter"
    channel="filesInChannel" directory="${in.file.path}" prevent-duplicates="true"
    filename-pattern="${file.pattern}">

    <int:poller id="poller" fixed-rate="1" task-executor="executor"/>
</int-file:inbound-channel-adapter>

<int-file:outbound-channel-adapter id="outputChannelAdapter" directory="${ok.file.path}" delete-source-files="true"/>

<task:executor id="executor" pool-size="10"/>

这是用10个线程处理所有传入的文件 . 我需要通过groupId拆分文件并让它们为每个groupId处理一个线程的步骤是什么?

谢谢 .

1 回答

  • 0

    假设组ID有限,您可以为每个组使用不同的适配器(使用单个线程;所有进入同一个通道);每个都有不同的模式 .

    或者您可以创建自定义 FileListFilter 并使用某种线程关联来将每个组中的文件分配给特定线程,过滤器仅返回此线程的文件 .

相关问题