title: How to use split on a stream in Apache Camel?
body: <p>When selecting a very large amount of data from a db, I want to use camel's <code>split</code>-component. It should split the stream into 100 objects and get it in iterator format.</p>
  
  <p>I successfully received multiple data from db, however failed during split.
  I'm getting data from <code>&lt;to&gt;</code>, but I don't know where to write this <code>&lt;to&gt;</code> syntax.</p>
  
  <pre><code>&lt;routes xmlns="http://camel.apache.org/schema/spring"&gt;
      &lt;route id="DbToKafka" streamCache="true"&gt;
          &lt;from uri="timer:foo?repeatCount=1" /&gt;
          &lt;split streaming="true"&gt;
              &lt;tokenize token="{" /&gt;
              &lt;to uri="sql:classpath:sql/get.sql" /&gt;
          &lt;/split&gt;
          &lt;log message="DATA : ${body}" /&gt;
          &lt;marshal&gt;
              &lt;json library="Jackson" /&gt;
          &lt;/marshal&gt;
          &lt;log message="JSON : ${body}" /&gt;
          &lt;to uri="kafka:test-topic?brokers={{kafka.brokers}}" /&gt;
          &lt;log message="data sended : ${body}" /&gt;
      &lt;/route&gt;
  &lt;/routes&gt;
  </code></pre>
  
  <blockquote>
    <p>2019-09-06 13:29:29.380 ERROR 10260 --- [3 - timer://foo]
    o.a.camel.processor.DefaultErrorHandler  : Failed delivery for
    (MessageId: ID-DESKTOP-225HFIE-1567744166599-0-2 on ExchangeId:
    ID-DESKTOP-225HFIE-1567744166599-0-1). Exhausted after delivery
    attempt: 1 caught: java.lang.NullPointerException: source</p>
    
    <p>Message History
    --------------------------------------------------------------------------------------------------------------------------------------- RouteId              ProcessorId          Processor<br>
    Elapsed (ms) [DbToKafka         ] [DbToKafka         ]
    [timer://foo?repeatCount=1<br>
    ] [         9] [DbToKafka         ] [split1            ]
    [split[tokenize{body() using token: ,}]<br>
    ] [         7]</p>
    
    <p>run without the split statement, get this result:
    [{"ROW_ID":"520","COM_CD_NM":"사용중"},{"ROW_ID":"521","COM_CD_NM":"메모지
    수수         "},{"ROW_ID":"522","COM_CD_NM":"상호대화<br>
    "},{"ROW_ID":"523","COM_CD_NM":"물품수수<br>
    "},{"ROW_ID":"524","COM_CD_NM":"기타<br>
    "},{"ROW_ID":"525","COM_CD_NM":"자격증변조          "},...]</p>
  </blockquote>