I have a problem with dynamically altering properties of a given route. I
have a timer which calls an endpoint. This endpoint fetches xx amount of
rows from a DB and uses the offset=$property.testproperty to know where to
begin fetching data from DB. If offset is 100 it starts at row 100 and moves
500 rows. Then when the timer starts the next round the offset will be
100+500=600 so starting from row 600 instead of row 100. I try to use
properties to do this. First starting from zero and retrieving the last row
from header from the endpoint. Then I try to add this header to setProperty
and then this property will be updated before the next run on the quartz
endpoint.

The problem is this property does not update in the route. I can see it gets
value in both processor and route but when it is updated it is not
registered in the route.

CODE:

@Override
        public void configure() throws Exception {
                // TODO Auto-generated method stub

        from("quartz2:" + BASE_URL +
"?trigger.repeatCount=-1&trigger.repeatInterval=3000")
            .routeId("Update Solr quartz route").log(LoggingLevel.INFO,
log.getName(), "Tick tack")
           
.choice().when(property("testproperty").isNull()).setProperty("testproperty").simple("0")
            .recipientList(
               
simple("http4://localhost:8080/criswsint/hentPerson/alle?offset=${property.testproperty}"))
            .setProperty("testproperty", simple("${in.header.lastid}"))
            .to("direct:foo");

        from("direct:foo")
            .routeId("Direct foo")
            .process(new Processor() {

                @Override
                public void process(Exchange exchange) throws Exception {
                    String theString = IOUtils.toString((InputStream)
exchange.getIn().getBody(), "UTF-8");
                    log.info(theString);
                    log.info((String) exchange.getProperty("testproperty"));
                }

            });
        }



--
View this message in context: 
http://camel.465427.n5.nabble.com/Dynamic-properties-in-a-camel-route-tp5801295.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to