I have this camel route where json values from an url are inserted into my database. code:
@Override
public void configure() throws Exception {
//voor elke tabel een andere route want bij wijzigingen json formaat crashed enkel 1 routebuilder
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
DataFormat jenkinsConfigFormat = new JacksonDataFormat(objectMapper, JenkinsConfiguration.class);
jenkinsConfigurations = configurationService.listJenkinsConfigurations();
logger.info("Starting routes for " + jenkinsConfigurations.size() + " jenkins configurations");
for (JenkinsConfiguration configuration : jenkinsConfigurations) {
from("timer://foo?fixedRate=true&period=120s&delay=20s")
.to(configuration.getUrl() + "/api/json")
.routeId(BUILD_ROUTE)
.unmarshal(jenkinsConfigFormat)
.enrich("direct:jenkinsconfig", new UseLatestAggregationStrategy())
.split(simple("${body.builds}"))
.choice()
.when(buildNumberAlreadyExists())
.otherwise()
.to("hibernate:be.kdg.teamf.model.Build")
.end();
from("timer://foo?fixedRate=true&period=120s&delay=20s")
.routeId(HEALTH_ROUTE)
.to(configuration.getUrl() + "/api/json")
.unmarshal(jenkinsConfigFormat)
.enrich("direct:jenkinsconfig", new UseLatestAggregationStrategy())
.split(simple("${body.healthReport}"))
.choice()
.when(healthReportAlreadyExists())
.otherwise()
.to("hibernate:be.kdg.teamf.model.HealthReport")
.end();
from("timer://foo?fixedRate=true&period=120s&delay=20s")
.routeId(MODULE_ROUTE)
.to(configuration.getUrl() + "/api/json")
.unmarshal(jenkinsConfigFormat)
.enrich("direct:jenkinsconfig", new UseLatestAggregationStrategy())
.split(simple("${body.modules}"))
.choice()
.when(moduleAlreadyExists())
.otherwise()
.to("hibernate:be.kdg.teamf.model.Module")
.end();
List<Build> jenkinsBuilds = buildService.getBuildsJenkinsProject(configuration);
DataFormat buildConfigFormat = new JacksonDataFormat(objectMapper, BuildDetail.class);
As you can see all jenkinsBuilds are loaded into a list:
List<Build> jenkinsBuilds = buildService.getBuildsJenkinsProject(configuration);
The first time when I run the program the list is empty. The second time when I run the program the list is able to get the wanted values from my database.
My question is: How can I configure my routes so the list contains the same values like when i run it the second time?
Is it maybe possible to restart the whole Configure() method?
thanks in advance