Anshuraj
Anshuraj

Reputation: 1

Running Camel-Context without using Thread.sleep() method

While starting the camel-context, Thread.sleep() method needs to call. Can somehow it can be made avoidable? Can it be done using wait() and notify() mechanism.

I am trying to implement the camel-context for my project. I need to remove the call to make thread waiting for some amount of time, like Thread.sleep(5000) used here. Can anybody has idea.

        CamelContext ctx = new DefaultCamelContext();
        CsvRouteBuilder builder = new CsvRouteBuilder(instId, csvcolMap);
        ctx.addRoutes(builder);
        ctx.start();
        Thread.sleep(5000);
        ctx.stop();

Logic for implementing camel-context without using Thread.sleep(5000)

Upvotes: 0

Views: 450

Answers (1)

Claus Ibsen
Claus Ibsen

Reputation: 55540

There is a Camel Main class you can use that can keep the JVM running. See the example at (for Camel 3): https://github.com/apache/camel/tree/master/examples/camel-example-main

For Camel 2.x its similar but the Main class on 2.x has less functionality than on 3.x.

Upvotes: 1

Related Questions