I have a working application that reads from a directory specified in a properties file and writes to a different directory. Here are the inbound and outbound channel adapters used for reading and writing.
<file:inbound-channel-adapter id="inputFileChannelAdapter" channel="fileIn" directory="${dir.monitor}"
auto-startup="false" prevent-duplicates="false" filename-pattern="*.done" >
<int:poller id="inputFilePoller" time-unit="SECONDS" fixed-delay="1" max-messages-per-poll="100" />
</file:inbound-channel-adapter>
<int:channel id="finishedFileChannel"/>
<file:outbound-channel-adapter id="finishedDataFiles" delete-source-files="true" auto-create-directory="false"
directory="${dir.finished}" channel="finishedFileChannel" />
I have a need to allow the directories to be changed while the application is running. I have created a control bus which allowed me to stop the polling service and change the input directory with the code below:
SourcePollingChannelAdapter adapter = context.getBean("inputFileChannelAdapter", SourcePollingChannelAdapter.class);
FileReadingMessageSource source = context.getBean("inputFileChannelAdapter.source", FileReadingMessageSource.class);
File monitorFileDir = new File("C:\newInput");
source.setDirectory( monitorFileDir );
However, I cannot figure out how to accomplish the same for the outbound channel adapter. I tried getting the reference to out bound channnel adapter and then creating a new EventDivenConsumer and FileWritingMessageHandler and reassign that to the reference, but it didn't work and I feel like I am heading down the wrong path with that solution. Any suggestions would be appreciated.