Hi, i'm refering to the Idempotent Consumer which will allow you to filter processed messages. you can get more details at http://camel.apache.org/idempotent-consumer.html Regards Fradj
2015-05-08 10:49 GMT+01:00 Mansour Al Akeel <[email protected]>: > Here's what I have so far. I am not sure if this is the best way, > However I can not find a way to store the variable for next quartz > run: > > > from("quartz2://sync/myTimer?trigger.repeatInterval=5000&stateful=true") > .routeId("myRoute") > .choice() > .when(property("last_id").isNotNull()) > .setBody( > constant("select id from student where id > :?last_id >= order by id")) > .otherwise() > // > .setBody(constant("select id from student order by id > ")).end() > .to("jdbc:ds?useHeadersAsParameters=true") > .log("sync db using sql stmt: ${in.body}") > .process(new Processor() { > > @Override > public void process(Exchange exchange) throws > Exception { > > // we need to iterate over the IDs and pull each > record > // from DB > > // set the last id or the last time stamp > exchange.setProperty("last_id", constant(2)); > } > }).log("done up to ID: ${property.last_id}"); > > Thank you. > > I am using camel 2.15.1 > > > On Thu, May 7, 2015 at 9:26 PM, Mansour Al Akeel > <[email protected]> wrote: > > Yes, I had a look earlier at this component. But I don't understand > > how it solve my problem. Can you please elaborate ? > > > > > > On Thu, May 7, 2015 at 7:56 PM, fradj zayen <[email protected]> wrote: > >> Hi, > >> did you tried to use sql component? > >> http://camel.apache.org/sql-component.html > >> Regards > >> Fradj > >> > >> 2015-05-07 15:08 GMT+01:00 Mansour Al Akeel <[email protected] > >: > >>> > >>> Usually I do this in plain java without using camel, however, I would > >>> like to start using camel for similar tasks. > >>> > >>> I need to use stateful job t opreserve state and variable for last > >>> run. One of these variable is the ID for the last record that was > >>> processed. I have seen that some developers mark a field with "DONE" > >>> in the originating table. However this is not possible as we don't > >>> have write permission to the originating table. And we can not read > >>> all the records, because the table may get big. > >>> > >>> > >>> > >>> So here's what I want to do: > >>> > >>> // poll the table every 5 seconds > >>> > >>> // if any new resords added or update_timestamp changed, then select > >>> those new records > >>> > >>> // use Message Enricher to get the new data from the DB. Iterate over > >>> them. > >>> > >>> // Send each updated record to message queue to be indexed by lucene > >>> or JDBC endpoint to be inserted into the target table. > >>> > >>> // store the last_id or timestamp for the processed recored to be used > >>> in the next run. > >>> > >>> A similar functionaity, I may need soon to poll CIMS sharepoint, where > >>> I don't have write access in the originating DB. > >>> > >>> I was not able to locate any example for using quartz2 stateful job. > >>> > >>> Any advice or pointer ? > >>> > >>> Thank you > >> > >> >
