4

春の統合の inbound-channel-adapter を使用しています。2 つの異なるディレクトリ (ファイル カテゴリごとに 1 つ) の下でポーリングし、そこにあるファイルを解析したいと考えています。私が使用するコードは次のとおりです。

<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>

両方の inbound-channel-adapter が同じチャネルを使用します。したがって、ファイルがどの inbound-channel-adapter から読み込まれたかを知りたいのです。

4

1 に答える 1

0

これらは私が考えることができる2つの方法です:

a. 各フローをヘッダー エンリッチャーに渡し、どのディレクトリから開始したかを示すカスタム ヘッダーを追加してから、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>

..

b. ペイロードは であるjava.io.Fileため、API を使用してこのファイルが属しているディレクトリを見つけ、何らかのアクションを実行できます。

于 2013-02-18T13:27:22.590 に答える