0
我有這個駱駝路線,其中從一個url的json值插入到我的數據庫。 代碼:apache駱駝休眠插入
@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);
正如你可以看到所有jenkinsBuilds被加載到一個列表:
List<Build> jenkinsBuilds = buildService.getBuildsJenkinsProject(configuration);
,當我運行的程序列表是空的第一次。 第二次運行程序時,該列表可以從我的數據庫中獲取所需值。
我的問題是:如何配置我的路線,使列表包含相同的值,如當我第二次運行它?
是否有可能重新啓動整個Configure()方法?
在此先感謝