Here:

http://camel.465427.n5.nabble.com/streaming-of-an-sql-resultset-td5547603.html

Claus recommends using "... a custom expression that returns an Iterator,
the the
splitter will use the iterator to read in a one row at a time."

I'm using groovy to do something like this.  Instead of a custom
expression, I'm using a processor.  The code does this:

1.  Processor creates a Query object.
2.  Processor passes a Closure to the Query object.
3.  Query object uses Spring's JDBCTemplate to execute the query.  It uses
passes the Closure to an implementation of Spring's ResultSetExtractor.
4.  ResultSetExtractor implementation constructs a ResultSet iterator with
the ResultSet and passes the iterator to the Closure.
5.  Closure calls the streaming/splitting route via a producer template.

I took this approach to ensure that the connection is automatically closed,
SQLExceptions are handled, etc.

If you used a custom expression, where would you clean up your JDBC
resources?

Reply via email to