Hi You most likely need to use the Polling Consumer EIP pattern http://camel.apache.org/polling-consumer.html
To have some timer trigger by X interval. For example every 10th second invoke your bean. http://camel.apache.org/timer.html Then you can use your BEAN to retrieve the list of data which you need to be written as files. You also have to decide if the file name is important or just use an auto generated UUID as name. If you need to dictate the filename, then you need to provide this information in a Header with the key: Exchange.FILE_NAME If so this makes the Splitter a bit more challeging as you need to provide BOTH - content of the file - name of the file And you can only have 1 return type in Java. So in this situation you can either - use a org.apache.camel.Message as return type, eg List<Message> where you store the file content in message IN body. And the file name in message IN header with that key. - Or not use the Splitter EIP but write the files directly from your BEAN. For that you can use the ProducerTemplate in Camel which makes this easy Just invoke this code line from your BEAN template.sendBodyAndHeader("file://somepath", contentOfFile, Exchange.FILE_NAME, "myFileName.txt"); And you can just define ProducerTemplate template in the parameter list of your bean public void writeFilesAndDoStuff(ProducerTemplate template) throws Exception { } Then the route is simply just from("timer://foo?period=5000").bean(MyCoolBean.class, "writeFilesAndDoStuff"); On Sat, Apr 24, 2010 at 10:56 PM, ChantingWolf <[email protected]> wrote: > > Dear all, > > Well, let's say, we have a very simple bean: > > <<<< > import java.util.*; > public class MySplitterBean { > public List<String> splitBody() { > List<String> answer = new ArrayList<String>(); > > answer.add("11"); > answer.add("12"); > return answer; > } > } >>>>> > > I want to use it as source for "from" clause. > And after this write output of splitBody function to separate files. > > Can someone help with a working example? > > Thanks > > -- > View this message in context: > http://old.nabble.com/Generating-multiple-files-based-on-DB-query-in-a-nice-way.-tp28351534p28352808.html > Sent from the Camel - Users mailing list archive at Nabble.com. > > -- Claus Ibsen Apache Camel Committer Author of Camel in Action: http://www.manning.com/ibsen/ Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus
