Home Ask Login Register

Developers Planet

Your answer is one click away!

krmanish007 February 2016

Apache Camel listener

I have created a router class and marked as a @Bean in @Configuration. One thing I am not very much sure is how frequently camel would be making a database call to get the select result? As soon as I have a new entry in the database, camel retrieve and process it.

public class SQLRouteBuilderForNewUserProcessing extends RouteBuilder {

    @Override
    public void configure() throws Exception {
        //files refer camel files endpoint
        //noop will not move or delete the files
        from("sql:" +
             "select id from users where status=" + Status.NEW.ordinal() +
             "?" +
             "consumer.onConsume=update users set status = " + Status.PROCESSING.ordinal()
             " where id = :#id")
            .bean(UserDataTranslator.class, "transformToUserData")
            .to("log:uk.co.infogen.users?level=INFO");
    }
}

Answers


Jérémie B February 2016

by default, the sql consumer pool the database every 500ms. You can configure this with consumer.delay

from("sql:select ... &consumer.delay=5000")
  .to(...)

see the documentation of the sql component


Shubhra Rai February 2016

consumer.delay long 500 Camel 2.11: SQL consumer only: Delay in milliseconds between each poll.

from http://camel.apache.org/sql-component.html

Post Status

Asked in February 2016
Viewed 3,531 times
Voted 8
Answered 2 times

Search




Leave an answer


Quote of the day: live life