You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by mossro <ro...@cgi.com> on 2014/05/12 16:08:19 UTC

File rotation

Hi,

I'm looking into using camel to support writing to file, the problem is that
these files will need to be rotated (new file after every x MB written).

I cannot obviously see anything on the File for dealing with this, and the
best i could think of is some how using <simple> with a choice to change the
to directory by using increment to change a suffix to a filename, but not
sure how i would even go about doing that.

Any help would be much appreciated.

Thanks,
Robin



--
View this message in context: http://camel.465427.n5.nabble.com/File-rotation-tp5751026.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: File rotation

Posted by mossro <ro...@cgi.com>.
The processor option might work quite well, thanks



--
View this message in context: http://camel.465427.n5.nabble.com/File-rotation-tp5751026p5751070.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: File rotation

Posted by Ra...@cognizant.com.
Have you explored file:name option ?

You can add processor to the route which can set this option based on the content size written to existing file so far. When limit is reached assign new value to the camelFileName and reset the count to calculate content size in processor.

For example:

Processor will have following logic:

        public void process(Exchange exchange) throws Exception {

                // you can also calculate total size written and then rotate the file.

                // For clarity i am changing fileName based on timestamp.

                long number = System.currentTimeMillis() % 9 ;

                String fileName = "File" + number + ".txt";


                exchange.getIn().setHeader("camelFileName", fileName);

        }


Route can look like this .....


    <route>
      <!-- read input from the console using the stream component -->
       <from uri="timer:foo?period=1s"/>
                  <transform>
                          <simple>Message at ${date:now:yyyy-MM-dd HH:mm:ss}</simple>
                  </transform>
                <process ref="rotationProcessor"/>
      <to uri="file://outdir?fileName=${file:name}"/>
    </route>


Hope this helps.

-Ravi



________________________________________
From: mossro [robin.moss@cgi.com]
Sent: Monday, May 12, 2014 7:38 PM
To: users@camel.apache.org
Subject: File rotation

Hi,

I'm looking into using camel to support writing to file, the problem is that
these files will need to be rotated (new file after every x MB written).

I cannot obviously see anything on the File for dealing with this, and the
best i could think of is some how using <simple> with a choice to change the
to directory by using increment to change a suffix to a filename, but not
sure how i would even go about doing that.

Any help would be much appreciated.

Thanks,
Robin



--
View this message in context: http://camel.465427.n5.nabble.com/File-rotation-tp5751026.html
Sent from the Camel - Users mailing list archive at Nabble.com.
This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful.

Re: File rotation

Posted by Willem Jiang <wi...@gmail.com>.
How do you write to the file?
I don’t think current camel support the File rotation automatically.
Please feel free to create a JIRA[1] for it.

[1]https://issues.apache.org/jira/browse/CAMEL 

--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.iteye.com (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem



On May 12, 2014 at 10:20:07 PM, mossro (robin.moss@cgi.com) wrote:
> Hi,
>  
> I'm looking into using camel to support writing to file, the problem is that
> these files will need to be rotated (new file after every x MB written).
>  
> I cannot obviously see anything on the File for dealing with this, and the
> best i could think of is some how using with a choice to change the
> to directory by using increment to change a suffix to a filename, but not
> sure how i would even go about doing that.
>  
> Any help would be much appreciated.
>  
> Thanks,
> Robin
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/File-rotation-tp5751026.html  
> Sent from the Camel - Users mailing list archive at Nabble.com.
>