add batching support to sql component
-------------------------------------

                 Key: CAMEL-4662
                 URL: https://issues.apache.org/jira/browse/CAMEL-4662
             Project: Camel
          Issue Type: New Feature
          Components: camel-sql
    Affects Versions: 2.8.2
            Reporter: Daniel Gredler


When I first started using Camel, I expected something like this to 
automatically batch SQL update statements:

from("direct:foo")
    .aggregate(constant("all"), new StringCollector())
    .completionSize(20) // batch size = 20
    .completionTimeout(5000)
    .to("sql:insert into foo values (#)?dataSourceRef=ds")

I was surprised when this wasn't the case, because in general batching SQL 
update statements is much more efficient than executing them individually, and 
is best practice when there is a lot of data involved.

The attached patch adds a "batch" attribute to the SQL component (default value 
is false), which should only be set to true for SQL update statements (insert, 
update, delete). If the "batch" attribute is true, then the interpretation of 
the inbound message body changes slightly -- instead of an Iterator of 
parameters, the component expects an Iterator that contains the parameter 
Iterators; the size of the outer Iterator determines the batch size.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to