2017-09-01 27 views
0

我想連續輪詢我的數據庫中的表並推送到Kafka。 我爲此使用apache駱駝。如何使用apache駱駝輪詢數據庫

我的路線如下: -

from(timer:every 1 sec). 
to(sql:select first 1000 * from myTable where id > myId). 
to(updateMyId). 
to(kafka:url).end() 

的問題是,它並不需要更新的身份識別碼中的下一次迭代。路由是靜態的,如果最初的myId = 1,那麼它保持從1開始輪詢。

如何動態更新myId?

+0

你在爲什麼投票?新的行?更新行?你使用的是什麼數據庫? – Namphibian

+0

輪詢新行。它的RDBMS,尚未修正,可能是MySQL,PostgreSQL等。 – user422489

回答

0

嘗試像this.set myId屬性,因爲它得到更新。

from(timer:every 1 sec). 
    to(sql:select first 1000 * from myTable where id >:#${property.myId}). 
    to(updateMyId). 
    to(kafka:url).end(); 

或者按照邏輯向bean移動。

to(sql:select first 1000 * from myTable where id >:#${property.myId}). 
    to(updateMyId).