how to write a timer for the method in camel

  1. Use loop and delay to simulate timer work
from("timer:repeatcount=1")
    .to("direct:first")
    .to("direct:second");

from("direct:second")
    .loopDoWhile(true)        // never ending loop, check loop component for more control
        .setBody(simple("Hello from timer at ${header.firedTime}"))
        .to("stream:out")
        .delay(1000)          // delay 1s, check delay component for more control
    .end();                   // end loop
  1. Use controlBus to start an inactive route of timer

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top