Parallel process and compare in Apache Camel

88 Views Asked by At

I'm currently working in a camel project where there is a need to trigger a scheduler that would read data from two separate tables(say table A and B) simultaneously, then compare their outputs against each other, prepare a final list and update the 1st table(Table A). This is my first usage of Apache Camel and I don't really have lot of ideas.. however sharing below a rough approach.. kindly help out.

something like this, I don't want to join the output instead want both the resultsets available for comparison.

from("direct:start)
            .processor("process1")
            .processor("process2")
.to("direct:compareAndUpdate");
1

There are 1 best solutions below

0
On

If you're using the SQL component to read tables, you can use the outputHeader option to store the query results in different headers.

Otherwise, you can use the Enrich EIP to accumulate the query results however you'd like.

Finally, you could do something simple and just copy each query result to a header or property. e.g.

.to("sql") // or whatever you're doing to get the data
.setHeader("results1", body())
.to("sql...") // or whatever you're doing to get the data
.setHeader("results2", body())