Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-4662

add batching support to sql component

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.8.2
    • 2.7.5, 2.8.4, 2.9.0
    • camel-sql
    • Patch Available
    • Moderate

    Description

      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.

      Attachments

        1. camel-4662.patch
          11 kB
          Daniel Gredler

        Activity

          People

            muellerc Christian Müller
            sdanig Daniel Gredler
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: