I am trying to get the List of employee details From Database and Push it in to External System using REST API. I am able to create a route for the above flow .
Also, I want to know the count of created and failure records. So i created a counter by setting property with value 0 and then increment the property value . When i try to increment the property value it always the same as what i initialized.
from("direct:test")
.setBody(constant("select name as name, location as location,mobile as mobile from employee"))
.to("jdbc:testdb")
.process(exchange ->{
// Custom Logic which will convert list of Employee Details
})
.split(body())
.setProperty("successrec", simple("0"))
.setProperty("failurerec", simple("0"))
.doTry()
.setProperty("successrec", simple("${property.successrec++}"))
.to("http://test/upload/employee")
.doCatch((Exception.class)).process( exchange ->{
Integer failureRecords=exchange.getProperty("failurerec",Integer.class);
exchange.setProperty("failurerec", failureRecords++);
});
I tried even using processor to set and get the property value, But it didn't worked . Is there any way i can have a counter over success and failure records.