Jul 4th, 2012, 06:51 AM
Is it posible to dynamically create a directory in a file:outbound-channel-adapter?
I have a requirement for the files being generated by a Spring Integration application similar to the work made by the DailyFolderAppender in log4j (a Log4j appender class that creates daily folders) plus some values obtained from the message being processed.
However, the destination directory is mandatory for creating a FileWritingMessageHandler (either via construction or by the int-file namespace: the int-file:outbound-channel-adapter element)
Thus, I can't use any value obtained from the message.
Does anyone else have a similar issue?
P.S.: my approach. Please, let me know if I'm doing something very wrong.
I've created a custom FileNameGenerator that creates the directory dynamically within the configured directory in the FileWritingMessageHandler in the very "generateFileName()" method, using the information from the Message provided as argument.
Besides, the method will return this dynamic path as part of the file name. I utilize "/" as file separator (not File.separator)
For the time being it works, even in Windows, because FileWritingMessageHandler will handle the files using a File object built with "File(File parent, String child)" that seems to resolve the path correctly.
I find this approach very fragile, so I'd like to hear from you any advice that you consider appropriate.