configuration - 使用配置属性来确定骆驼中的循环计数
问题描述
这是我的代码。我正在弄清楚如何使用配置属性来确定循环计数。配置属性似乎将其读取为字符串类类型。
PropertiesComponent pc = new PropertiesComponent();
pc.setLocation("classpath:app.properties");
getContext().addComponent("properties", pc);
from("direct:a")
.routeId("CheckDevices")
.loop("{{Device.count}}") //loop expect a integer. how do i convert ?
.to("mock:result");
配置文件:
应用程序属性
设备.Count=5
解决方案
.loop(Integer.valueOf("{{Device.count}}") // this does the job