Camel
  1. Camel
  2. CAMEL-4662

add batching support to sql component

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.8.2
    • Fix Version/s: 2.7.5, 2.8.4, 2.9.0
    • Component/s: camel-sql
    • Labels:
    • Patch Info:
      Patch Available
    • Estimated Complexity:
      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.

      1. camel-4662.patch
        11 kB
        Daniel Gredler

        Activity

        Hide
        Christian Müller added a comment -

        Thank you Daniel for the patch

        Show
        Christian Müller added a comment - Thank you Daniel for the patch
        Hide
        Daniel Gredler added a comment -

        Hi Christian,

        Have you had a chance to look at the patch? Let me know if anything needs to be changed.

        Take care,

        Daniel

        Show
        Daniel Gredler added a comment - Hi Christian, Have you had a chance to look at the patch? Let me know if anything needs to be changed. Take care, Daniel
        Hide
        Christian Müller added a comment -

        I will work tomorrow on it...

        Show
        Christian Müller added a comment - I will work tomorrow on it...
        Hide
        Daniel Gredler added a comment -

        patch to trunk

        Show
        Daniel Gredler added a comment - patch to trunk

          People

          • Assignee:
            Christian Müller
            Reporter:
            Daniel Gredler
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development