camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Gardner <>
Subject Streaming ResultSet Revisted
Date Fri, 03 Jan 2014 17:24:29 GMT

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

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message