On Thu, Sep 30, 2010 at 12:22 PM, Tarjei Huse <tar...@scanmine.com> wrote:
>  On 09/29/2010 01:31 PM, Claus Ibsen wrote:
>> On Wed, Sep 29, 2010 at 12:44 PM, Tarjei Huse <tar...@scanmine.com> wrote:
>>>  Hi, I got a huge file I want to split into smaller chunks and send each
>>> chunk as a new message using the splitter. The file contains Protobuf
>>> objects so I cannot use any of the normal splitting methods, but I want
>>> to use the streaming() method on the route. How do I create a splitter
>>> that supports this?
>>>
>> Just let the method return an Iterator type and then you can return
>> the data in chunks as you like.
>> The streaming mode will then walk the iterator on demand until hasNext
>> returns false.
> Duh!
>
> I'm quite sure that you have answered this question to me before and I
> have forgotten. Sorry about that. I'll try to update the wiki so I do
> not repeat my questions.
>
> One thing though, do I have to set streaming mode explicitly when using
> an iterator or will that come implicitly then?
>

No the streaming() mode actually only controls whether Camel will walk
the iterate one time, or on-the-fly.
One time means it walks it beforehand and stores the result in memory,
so it knows the complete size before splitting begins.
That information is then populated on the Exchange. So you know that
the total size is eg 8. For streaming() you will not know the total
size.



> Regards,
> Tarjei
>>
>>> I.e:
>>> FileSplitter fs = new FileSplitter();
>>>  from("file://myfile")
>>>            .routeId(InjectFiles.class.getSimpleName())
>>>            .split().method(fs,
>>> "splitMessage").streaming().stopOnException()
>>>
>>>
>>> --
>>> Regards / Med vennlig hilsen
>>> Tarjei Huse
>>> Mobil: 920 63 413
>>>
>>>
>>
>>
>
>
> --
> Regards / Med vennlig hilsen
> Tarjei Huse
> Mobil: 920 63 413
>
>



-- 
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

Reply via email to