[英]Spring Integration polling inbound-channel-adapter on multiple servers
[英]multiple inbound-channel-adapter of spring integration using the same channel
我正在使用Spring集成的入站通道適配器。 我想在兩個不同的目錄下進行輪詢 - 每個文件類別 - 並解析位於那里的文件。 我使用的代碼是:
<int:channel id="inputChannel"/>
<file:inbound-channel-adapter id="fileInOne"
directory="myDirOne"
auto-create-directory="true"
channel = "inputChannel">
<int:poller id="one" cron="1/10 * * * * *"/>
</file:inbound-channel-adapter>
<file:inbound-channel-adapter id="fileInTwo"
directory="myDirTwo"
auto-create-directory="true"
channel = "inputChannel">
<int:poller id="two" cron="1/10 * * * * *"/>
</file:inbound-channel-adapter>
兩個入站通道適配器都使用相同的通道。 所以我想知道文件加載的入站通道適配器。
這是我能想到的兩種方式:
一種。 將每個流通過標題集合,添加一個自定義標題,告訴您從哪個目錄開始,然后再輸入inputChannel。
<file:inbound-channel-adapter id="fileInOne"
directory="myDirOne"
auto-create-directory="true"
channel = "dirOneEnricher">
<int:poller id="one" cron="1/10 * * * * *"/>
</file:inbound-channel-adapter>
<int:header-enricher input-channel="dirOneEnricher" output-channel="inputChannel">
<int:header name="fileCategory" value="dirOneTypeCategory"/>
</int:header-enricher>
..
灣 由於有效負載是java.io.File
,因此您可以使用API來查找此文件所屬的目錄並執行某些操作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.