2013-02-18 38 views
4

我正在使用弹簧集成的入站通道适配器。我想要在两个不同的目录下进行轮询 - 一个文件类别 - 并解析位于那里的文件。我使用的代码是:使用相同通道的弹簧集成的多个入站通道适配器

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

两个入站通道适配器使用相同的通道。所以我想知道从哪个入站通道适配器加载文件。

回答

0

这些是我能想到的两种方式:

a。将每个流通过一个头richher,添加一个自定义头,告诉你从哪个目录开始,然后到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​​找出该文件属于哪个目录并采取一些措施。

+0

谢谢你的回答!我会尝试。我想问别的。这种配置会影响效率吗?对每个入站通道适配器最好使用不同的通道? – pbal 2013-02-19 09:13:50

相关问题