I'd started a Spring Integration project using a file-based inbound-channel-adapter and so far it's working well. But I realized that I don't seem to have implemented the concept correctly and would like to seek some advice here on how to correct it.
In the Spring XML declaration, the adapter is declared as:
<file:inbound-channel-adapter id="filesIn" directory="file:/tmp/input" prevent-duplicates="true">
<int:poller id="poller" fixed-delay="500"/>
</file:inbound-channel-adapter>
<int:service-activator input-channel="filesIn" output-channel="filesOut" ref="fileHandler" method="handleUpdate" />
<bean id="fileHandler" class="com.myproj.integration.FileUpdater"/>
<file:outbound-channel-adapter id="filesOut" directory="file:/tmp/output" delete-source-files="true" />
In my FileUpdater class, method handleUpdate() is given an input of type File:
public File handleUpdate(File input) throws ParseException, FileNotFoundException, IOException {
......
}
Since I'm able to read the file using the input parameter and get all I need, I've been able to do everything that I need to in order to complete my business logic.
However, I know very well that the way I'm handling this right now (reading the File directly from file system in all my service activators) means that I am unable to change to use another inbound channel adapter (say HTTP) without impacting the code for the entire integration chain.
I reckon that the Message object passed through the integration chain should be the contents of the File itself rather than a reference to the File on the file system itself.
Question is: does Spring Integration do the work of getting the contents of the file into my Message payload? Or do I need to do some transformation to do that myself?