![](/img/trans.png)
[英]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.