Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

apache camel route to split sql results

I am trying to do is select all rows from DB, and for each row update some column for that row. Below is my camel route.

from("direct:insert").
from("sql:select * from my_table").
split(body()).
log("${body[id]}").
end();

I use the below code to start this route...

context.createProducerTemplate().sendBody("direct:insert", null);

Problem is it happens multiple times (i.e. all the id's from my_table are printed around 18 times!!). How do i make it happen just once?

like image 202
noi.m Avatar asked Nov 20 '25 06:11

noi.m


1 Answers

Below code worked fine for me..

from("direct:insert").
to("sql:select * from my_table").
split(body()).
log("${body[id]}").
end();
like image 191
noi.m Avatar answered Nov 21 '25 19:11

noi.m



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!