stream result of iterator to a file

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

stream result of iterator to a file

anoordover
I have two questions:
I would like to stream the result of an iterator to a file.
I succeeded in doing that using a split with a factory class that creates my iterator.
The name of the file is set dynamically in the header of the exchange.
So far I have no problem at all.

But I also want to write the stream to the database in a BLOB.
For this I have a kind of a writer which adapts a "dao" (not a real dao but an interface that is made available via camel using the activemq component) so that I am able to stream to this BLOB.
But the problem is that the first time I write a set of results to the database a UID is generated for this row.
The next write use this UID to retrieve the stored document and append the new set of result.
I "must" do it this way because the interaction with this database is only available via a camel activemq endpoint. In the interface on this route I have two methods available (saveDocument, appendToDocument).

For this solution I need to instantiate that writer for each "master" exchange.
How can I make this instance (on a per exchange basis) available in my route as a consumer?

Should I think about another solution?