Results 1 to 10 of 10

Thread: file outbound-channel-adapter filename-generator not working?

  1. #1
    Join Date
    Sep 2009
    Posts
    3

    Exclamation 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:

    Code:
    ...
    <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:
    Code:
    public class FilenameGenerator extends DefaultFileNameGenerator {
    
    	@Override
    	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. #2
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

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

  3. #3
    Join Date
    Sep 2009
    Posts
    3

    Default

    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. #4
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    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?

    Thanks,
    Mark

  5. #5
    Join Date
    Sep 2009
    Posts
    3

    Lightbulb

    I opened INT-805 about dynamically creating directories.

  6. #6
    Join Date
    May 2007
    Location
    Netherlands
    Posts
    614

    Default

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

  7. #7
    Join Date
    Sep 2009
    Posts
    12

    Default Int-805

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

  8. #8
    Join Date
    Dec 2010
    Posts
    2

    Default

    Quote 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. #9
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    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. #10
    Join Date
    Dec 2010
    Posts
    2

    Default

    Quote 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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •