camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <>
Subject Re: Passing input stream to the route
Date Fri, 10 Feb 2012 03:42:41 GMT
I guess you just need to pass the lines into camel, you don't need to 
put the result into other stream.
In this case you may consider to extends the StreamComponent and pass 
the csvDataStream into it.

Then you don't need to use the producer template any more.

On Thu Feb  9 20:41:49 2012, Henryk Konsek wrote:
> Hi guys
> Recently I've been assigned to the task of implementing callback
> interface that provides InputStream of CSV data. My task was to take
> the stream I received from the callback and pass it to the Camel to
> perform processing on each line read. Something like:
> interface DataProviderCallback {
>     void dataAvailable(InputStream csvData);
> }
> class CamelDataProviderCallback implements DataProviderCallback {
>     @Autowire
>     CamelContext context;
>     void dataAvailable(InputStream csvDataStream) {
>       // pass csvDataStream to Camel and do not block
>     }
> }
> Of course the mentioned stream of data produces gigabytes of CSV
> records so I cannot read it entirely into the memory. I need to read
> it line by line (i.e. record by record) and pass each line to the
> Camel. I got some good experience with Camel Stream component for such
> use cases. Unfortunately I cannot pass existing InputStream instance
> to it.
> I solved this using background thread (my callback cannot block next
> ones) in which I read lines from the stream and pass them to the Camel
> one by one (using ProducerTemplate). This solution is fine for my
> particular purpose but not elegant in general.
> What would be your suggestion to solve this issue? How to you handle
> existing InputStream instances?

Blog: (English) (Chinese)
Twitter: willemjiang 
Weibo: willemjiang 

View raw message