title: Syncing two tables using Apache Camel
body: <p>I've just started using Apache Camel and I would like to try to synchronize two tables. Both tables have two columns, "id" and "name". The scenario would query the first table, check for existence of each record in the second table, and insert each record that doesn't exist. Here is my attempt:</p>
  
  <pre><code>&lt;camel:camelContext id="test"&gt;
      &lt;camel:route&gt;
          &lt;camel:from uri="timer://kickoff?period=5s"/&gt;
          &lt;camel:to uri="sql:select id, name from table1?dataSourceRef=dataSource"/&gt;
          &lt;camel:split&gt;
              &lt;camel:simple&gt;body&lt;/camel:simple&gt;
              &lt;camel:to uri="sql:select * from table2 where id = #?dataSourceRef=dataSource" /&gt;
              &lt;camel:choice&gt;
                  &lt;camel:when&gt;
                      &lt;camel:simple&gt;${header.CamelSqlRowCount} == 0&lt;/camel:simple&gt;
                      &lt;camel:to uri="sql:insert into table2 (id, name) values (#, #)?dataSourceRef=dataSource" /&gt;
                  &lt;/camel:when&gt;
              &lt;/camel:choice&gt;
              &lt;camel:to uri="mock:result" /&gt;
          &lt;/camel:split&gt;
      &lt;/camel:route&gt;
  &lt;/camel:camelContext&gt;
  </code></pre>
  
  <p>The problem here is that by the time I reach <code>insert into table2</code>, the original message (the one containing the data) is lost, as I had to make another query in the meantime (where I check for data in the second table). Is my approach good and how can I retrieve the message that contains the data?</p>