2 Replies Latest reply on Apr 17, 2009 10:37 AM by Roger Joelsson

    Possible bug? Route into several files

    Roger Joelsson Novice

      Hi everyone,


      I have a short question regarding the camel-file component. I have as RouteBuilder as follows:




      .method("myBean", "myMethod")



      When I drop a message into the data/in folder, it gets processed by the myBean.myMethod as follows:


      public List();

        //...populated result with a number of records

        return result;



      Now I expect SEPARATE files to be generated, i.e. one for each record in the result list. This is though NOT the case, only one file is generated, regardless of what myMethod returns.


      Why is this? Am I doing something wrong (probably) or have I found an issue here?


      PLEASE someone, help!




        • 1. Re: Possible bug? Route into several files
          Claus Ibsen Master



          The issue is possible that the original filename is propagated and then when the file producer is about to write a file (does this for each splitted line) then it sees the original filename and appends to this file. The same happens for the next splitted line to be written.


          To use new files for each line you must either:

          - provide an unique filename as a header

          - remove the filename header so Camel generates an unique filename


          In Camel 1.x the filename is stored in the header using the key:

          - FileComponent#HEADER_FILE_NAME

          that is a constant for the key: org.apache.camel.file.name


          In Camel 2.0 its a bit easier to remember as the key is

          - CamelFileName

          • 2. Re: Possible bug? Route into several files
            Roger Joelsson Novice

            Thanks a lot for your clues -- and yes, the filename proved to be the issue! After modifying the resulting filename (using 'expression' file component parameter), the filename was changed and several files were created!