You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by imranrazakhan <im...@gmail.com> on 2016/06/06 16:48:39 UTC

Loop in Routers

Hi,

I am using Camel Loop in router like below, please suggest any improvement

from("direct:terminateEvents")
.to("sql:select event_id from events where id = 32611 and status != 777")
.setProperty("totalEvents", simple("${body.size}") )
.setProperty("counter", simple("0") )
.loopDoWhile(simple("${property.counter} < ${property.totalEvents}"))
    .to("sql:update ABC set status=333 where event_id =:${body[
${property.counter} ]}")            
    .setProperty("counter",simple("${property.counter}++") )
.end()
.to("direct:Nex")
.end(); 



--
View this message in context: http://camel.465427.n5.nabble.com/Loop-in-Routers-tp5783506.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Loop in Routers

Posted by arno noordover <an...@gmail.com>.
I would suggest to let the database solve this:
for example update ABC set status=333 where event_id in (...your first
statment...)



--
View this message in context: http://camel.465427.n5.nabble.com/Loop-in-Routers-tp5783506p5783562.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Loop in Routers

Posted by imranrazakhan <im...@gmail.com>.
i m not facing any problem, its design questions any better alternative?



--
View this message in context: http://camel.465427.n5.nabble.com/Loop-in-Routers-tp5783506p5783508.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Loop in Routers

Posted by Brad Johnson <br...@mediadriver.com>.
Is there a problem with it?

On Mon, Jun 6, 2016 at 11:48 AM, imranrazakhan <im...@gmail.com>
wrote:

> Hi,
>
> I am using Camel Loop in router like below, please suggest any improvement
>
> from("direct:terminateEvents")
> .to("sql:select event_id from events where id = 32611 and status != 777")
> .setProperty("totalEvents", simple("${body.size}") )
> .setProperty("counter", simple("0") )
> .loopDoWhile(simple("${property.counter} < ${property.totalEvents}"))
>     .to("sql:update ABC set status=333 where event_id =:${body[
> ${property.counter} ]}")
>     .setProperty("counter",simple("${property.counter}++") )
> .end()
> .to("direct:Nex")
> .end();
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Loop-in-Routers-tp5783506.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>