Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9052765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:15:41+00:00 2026-06-16T13:15:41+00:00

I’ve just started using Apache Camel and I would like to try to synchronize

  • 0

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:

<camel:camelContext id="test">
    <camel:route>
        <camel:from uri="timer://kickoff?period=5s"/>
        <camel:to uri="sql:select id, name from table1?dataSourceRef=dataSource"/>
        <camel:split>
            <camel:simple>body</camel:simple>
            <camel:to uri="sql:select * from table2 where id = #?dataSourceRef=dataSource" />
            <camel:choice>
                <camel:when>
                    <camel:simple>${header.CamelSqlRowCount} == 0</camel:simple>
                    <camel:to uri="sql:insert into table2 (id, name) values (#, #)?dataSourceRef=dataSource" />
                </camel:when>
            </camel:choice>
            <camel:to uri="mock:result" />
        </camel:split>
    </camel:route>
</camel:camelContext>

The problem here is that by the time I reach insert into table2, 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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T13:15:42+00:00Added an answer on June 16, 2026 at 1:15 pm

    When you call the 2nd SQL to check, then you can use the content enricher EIP to “merge” the result of this call with the original message. In your case, you only need to know if there was a row or not, and store that in a header.

    The content enricher eip is documented here: http://camel.apache.org/content-enricher.html, see for example the enrich.

    The caveat is that you would need to use a java code and implement an AggregationStrategy that implements the “merge” logic.

    You can also do as Ben suggests to store the 1st data in a header (or property on the exchange), which you can access later.

    Though looking at this from the EIP perspective, then its the content enricher EIP that best covers this use-case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables with like below codes: Table: Accounts id | username |
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
I would like to run a str_replace or preg_replace which looks for certain words
I have thousands of HTML files to process using Groovy/Java and I need to
I would like to count the length of a string with PHP. The string
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.