簡體   English   中英

Spring Integration-按組並行處理文件

[英]Spring Integration - parallel file processing by group

我正在嘗試通過一個簡單的任務對Spring Integration進行實驗。 我有一個接收傳入文件的文件夾。 這些文件以組ID命名。 我希望按順序處理同一groupId中的所有文件,但是具有不同groupIds的文件可以並行處理。

我開始整理這樣的配置:

<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處理一個線程的步驟是什么?

謝謝。

假設組id的數量有限,則可以為每個組使用不同的適配器(具有單個線程;所有線程都饋入同一通道); 每個都有不同的模式。

或者,您可以創建一個自定義FileListFilter並使用某種線程相似性將每個組中的文件分配給特定線程,而過濾器僅返回該線程的文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM