Announcement Announcement Module
No announcement yet.
file outbound-channel-adapter filename-generator not working? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • file outbound-channel-adapter filename-generator not working?

    I'm using Spring Integration 1.0.3.RELEASE, and have troubles getting the filename-generator to work.

    My spring configuration is as follows:

    <integration:channel id="file-channel" />
    <file:outbound-channel-adapter directory="/tmp/integration" channel="template-channel" filename-generator="filename-generator" />
    <bean id="filename-generator" class="some.FileNameGenerator" />
    The implementation of the filename generator is as follows:
    public class FilenameGenerator extends DefaultFileNameGenerator {
    	public String generateFileName(Message<?> message) {
    		System.out.println("generateFileName(" + message.getPayload() + ")");
    		String filename = super.generateFileName(message);
    		System.out.println("Generate filename: " + filename);
    		if (message.getPayload() instanceof SomeMessage) {
    			filename = "example_filename.txt";
    		System.out.println("Generate filename: " + filename);
    		return filename;
    I see the filename-generator getting called, but no file is written to disk. When I replace "some.FileNameGenerator" with "org.springframework.integration.file.DefaultFileN ameGenerator" no file is written either. When I remove the filename-generator attribute, the file gets written.

    Am I doing something wrong, or is this a bug?

  • #2
    I'll try to reproduce this. If it's behaving as you described, then it is a bug. Maybe something else is happening.


    • #3
      For now I've solved it by adding a FileHeaders.FILENAME header, but I'm curious if you can reproduce this, or if I made a mistake somewhere!

      By the way, is it somehow possible to let the outbound-channel-adapter create sub-directories? Or do I have to write my own FileWritingMessageHandler for that?

      Use-case: I would like to write my files to BASE/YYYY-mm-dd/id.msg


      • #4
        Actually, we have been planning to add support for dynamic generation of the outbound directory (or sub-directories). In fact, it's part of a general trend for making output targets more dynamic (e.g. WebService URI with DestinationProvider strategy, etc.).

        Could you please create a new issue in JIRA with a brief description of your use-case?



        • #5
          I opened INT-805 about dynamically creating directories.


          • #6
            Is the problem with generating fileNames resolved now? If not, could you create and issue for that too?


            • #7

              What is the status of this feature? I need to be able to use the same use case for dynamic outbound subdirectories.


              • #8
                Originally posted by armandlek16 View Post
                What is the status of this feature?
                I just voted this one on Jira. Is there anything going on with this one?


                • #9
                  What version of Spring Integration are you using now? The main reason I ask is that if we do address the issue, it will most likely be in an upcoming 2.0.x release.


                  • #10
                    Originally posted by Mark Fisher View Post
                    What version of Spring Integration are you using now?
                    I am using 2.0.1.RELEASE.

                    As a side note. Funny that Maven Repository is showing 2.0.0.RELEASE as the latest version.