camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Dudgeon <>
Subject How to stream to file
Date Mon, 26 May 2014 16:14:06 GMT
I'm having problems working out how to write my output to file.
I'm wanting something that can work with the File component so that I 
get the benefit of its flexibility (and can use FTP etc.).
But the problem is that I need to write the data using a class that uses 
a File or OutputStream. Its something like this:

public class MyDataWriter {
     public MyDataWriter(File file) { }
     public MyDataWriter(OutputStream out) { }

     public void write(MyData bar) { ... }

The workflow is something like this:
1. read data from file using File consumer
2. split it up into parts (e.g. lines) using a Splitter (streaming)
3. Process each part
4. Write modified parts to new file

The data is potentially large, so needs to support streaming.
I've hacked something up using AggregationStrategy for step 4 which sort 
of works, but I feel there should be a better way.
I could write my own Component/Endpoint, but its feels like I'd be 
re-writing the File component.
Somehow it feels like I should be able to use the File component (send 
some type of OutputStream to it?) but I can't figure out how.

Any advice would be very welcome.

View raw message