Hi Try with Camel 2.6 as we have fixed some issues with the splitter.
On Sun, Jan 23, 2011 at 2:23 PM, Christian Mueller <christian.muel...@gmail.com> wrote: > > Hello list, > I'm using Camel 2.4 (inside FUSE ESB 4.3). For a POC (prove of concept) I > have to read a file with multiple address lines like this one: > {code} > 1,Hahnstr,1,60525,Frankfurt > ... > 10000,Hahnstr,10000,60525,Frankfurt > {code} > > Afterwards I have to call a web service (which makes the address updates on > our customer database). The web service respond with the id (the first > number in the input file) and the status (UPDATED). I have to write a result > file for each processed record which should looks like (the order of the > entries is not relevant): > {code} > 1,UPDATED > ... > 10000,UPDATED > {code} > > My first solution which works fine was the following: > > {code} > from("file:src/test/data?noop=true").routeId("POC-main") > .split(body().tokenize("\n"), new > PocResultAggregationStrategy()).parallelProcessing().streaming() > .inOut("direct:addressService") > .end() > .inOnly(targetFileResourcePath); > > from("direct:addressUpdateService").routeId("POC-addressUpdateService") > .convertBodyTo(UpdateAddress.class) > .inOut("cxf:bean:addressService") > .convertBodyTo(String.class); > {code} > > After thinking about this solution, it has a few cons: > 1) I didn't use a persistent aggregator which could be result in loosing all > aggregated messages if someone shutdown the ESB. > 2) The Aggregator looks a bit 'overingenieurd' for this requirement because > I only append new lines. > > I tryied to implement a smarter solution and came up with this one: > > {code} > from("file:src/test/data?noop=true").routeId("POC-main") > .split(body().tokenize("\n")).parallelProcessing().streaming() > .inOut("direct:addressService") > .inOnly("file:target/outbox?fileExist=Append") > .end(); > > from("direct:addressUpdateService").routeId("POC-addressUpdateService") > .convertBodyTo(UpdateAddress.class) > .inOut("cxf:bean:addressService") > .convertBodyTo(String.class); > {code} > > But unfortunately, the result file only contained 9897 lines instead of > 10000. :-( > I couldn't find an option in the file-component to lock the file, so that > only one thread can manipulate the file in one time. > > My question is: Does the Camel file producer has an option for that? If not, > should the file producer has an option like: writeLock=fileLock (similar to > the readLock option of the file consumer)? Then maybe we also need an option > to specify how long Camel should wait for the lock until it fails... > > What you are thinking? > > Thanks in advance for your feedback, > Christian > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Using-Splitter-and-file-producer-with-option-fileExist-Append-failed-tp3353618p3353618.html > Sent from the Camel - Users mailing list archive at Nabble.com. > -- Claus Ibsen ----------------- FuseSource Email: cib...@fusesource.com Web: http://fusesource.com Twitter: davsclaus Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/