Wso2 如何在每次任务调用之间保留属性值
我使用WSO2 ESB调度任务从外部系统获取数据,该任务每5秒调用一次我的代理服务。在我的代理服务中,我使用了属性名“startTime”和“endTime”,这意味着我要从“startTime”到“endTime”提取数据。每次任务调用“开始时间”和“结束时间”应增加5秒。 但ESB似乎无法在每次任务调用之间存储这些属性(startTime和endTime)。我尝试使用脚本编写“开始时间”: 明白了吗Wso2 如何在每次任务调用之间保留属性值,wso2,wso2esb,Wso2,Wso2esb,我使用WSO2 ESB调度任务从外部系统获取数据,该任务每5秒调用一次我的代理服务。在我的代理服务中,我使用了属性名“startTime”和“endTime”,这意味着我要从“startTime”到“endTime”提取数据。每次任务调用“开始时间”和“结束时间”应增加5秒。 但ESB似乎无法在每次任务调用之间存储这些属性(startTime和endTime)。我尝试使用脚本编写“开始时间”: 明白了吗 <property expression="get-property('registr
<property expression="get-property('registry', fn:concat('conf/data_task/',get-property('id'),'/startTime'))"
name="startTimeInReg" scope="default" type="STRING"/>
我可以得到“startTime”,但它的值保持不变,我发现在2到3次调度任务调用后(可能elaps超过15s),startTime的值会发生变化
我认为这可能是ESB缓存造成的,在调用updateResource方法后,我如何立即提交startTime值的更改。或者如何解决此问题。尝试将您的价值保存在治理注册表中:
mc.getConfiguration().getRegistry().newResource("gov:/trunk/test/MyCounter.txt",false); // create the resource the 1st time, does nothing the others
mc.getConfiguration().getRegistry().updateResource("gov:/trunk/test/MyCounter.txt", startTimeInReg.toString());
另一个解决方案,请查看创建“全局”计数器的示例(重新启动ESB时丢失):
它可以与第二种解决方案配合使用。但是第一个解决方案在几秒钟后仍然无法获得change属性,这是因为ESB缓存机制吗?我使用第一个解决方案将一些数据放入缓存。因此,你让我发现这些变化不是立即有效的。。。
mc.getConfiguration().getRegistry().newResource("gov:/trunk/test/MyCounter.txt",false); // create the resource the 1st time, does nothing the others
mc.getConfiguration().getRegistry().updateResource("gov:/trunk/test/MyCounter.txt", startTimeInReg.toString());
<script language="js"><![CDATA[
var curValue = mc.getEnvironment().getServerContextInformation().getProperty("MyCounter");
if (curValue == null) {
curValue = 0;
} else {
curValue++;
}
mc.getEnvironment().getServerContextInformation().addProperty("MyCounter",curValue);
mc.setProperty("MyCounter",curValue);
]]></script>