I wonder if split().shareUnitOfWork() would help here? On Mar 8, 2013, at 14:02, Claus Ibsen wrote:
> On Fri, Mar 8, 2013 at 2:39 PM, jeff <jflebesc...@gmail.com> wrote: >> the more performante way looks to do : >> >> from("file://C:/Temp/camel/input_test/?noop=true") >> .split() >> .tokenize("\n") >> // Business lock with possible reject / enrich etc ... >> .streaming() >> >> .to("stream:file?fileName=C:/Temp/camel/output_test/out.csv") >> .end() >> .end(); >> >> But the stream is not closed ... Please help, I have to finish my proof of >> concept ! :) >> > > Just use a bean to write to the file, and keep the FileOutputStream > open until the last message is processed. > > Something a long the lines of: > > public class MyFileWriter { > > private FileOutputStream fos; > > public void writeMyStuff(String data, @Header("CamelSplitCompleted") > boolean done) { > if (fos == null) { > fos = new FileOutputStream(new File("xxxx")); > } > fos.write(data.getBytes()); > if (done) { > fos.close(); > fos = null; > } > } > } > > And then use this bean in the splitter instead of the to:stream > > > .bean(MyFileWriter.class); > > > > >> Thanks >> >> JF >> >> >> >> >> >> -- >> View this message in context: >> http://camel.465427.n5.nabble.com/Write-enriched-data-after-a-split-in-a-file-tp5728761p5728829.html >> Sent from the Camel - Users mailing list archive at Nabble.com. > > > > -- > Claus Ibsen > ----------------- > Red Hat, Inc. > FuseSource is now part of Red Hat > Email: cib...@redhat.com > Web: http://fusesource.com > Twitter: davsclaus > Blog: http://davsclaus.com > Author of Camel in Action: http://www.manning.com/ibsen