Reputation: 541
I am using inbound-channel-adapter of spring integration. I want to poll under two different directories -one per file category- and parse the files that are located there. The code that i use is:
<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>
Both inbound-channel-adapters use the same channel. So I want to know from which inbound-channel-adapter the file was loaded.
Upvotes: 5
Views: 3336
Reputation: 49935
These are two ways that I can think of:
a. Pass each of the flows through a header enricher, add a custom header which tells you which directory you started from, and then to the 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. Since the payload is a java.io.File
, you can use the API's to find out which directory this file belongs to and take some action.
Upvotes: 0