我是骆驼的起跑者。
我使用javascript实现了camel xml中的验证逻辑。
最初,当第一个事件(包含一些记录的文件)进入时,加载javascript需要一些时间。这种情况是发现的。在这种情况下,由于javascript的加载时间,只有第一条记录很慢,其余的记录正常执行。问题是下一个事件(一个文件)即将到来。Camel再次尝试加载javascript。因此,处理每个文件都需要加载时间,因此整体性能已经下降。
我想修改一些逻辑,使camel只能加载它一次。
我该如何解决这个问题?
<unmarshal id="_FileParsing">
<bindy
classType="com.openmzn.ktds.dao.volte.input.VoLTEBody"
locale="korea" type="Fixed"/>
</unmarshal>
<to id="_validateParsing" uri="language:javascript:classpath:spring/rules/volte/volte.js"/>
<multicast id="_FileDistributor" parallelProcessing="false">
<toD id="_ProcessNRat" uri="direct:NRAT"/>
<toD id="_ProcessDrop" uri="direct:DROP"/>
</multicast>Javascript文件
var bodyList = exchange.in.getBody(ArrayList.class);
if(!CollectionUtils.isEmpty(bodyList)) {
for (total_count = 0; total_count < bodyList.size(); total_count++) {
uBody = bodyList[total_count];
enriched = enrich(uBody);
result = validate(enriched);
resultList.add(result);
...
}
function enrich(uBody) {
...
}
function validate(enriched) {
...
}发布于 2019-07-19 15:20:34
您可以打开cacheScript=true,请参阅文档https://github.com/apache/camel/blob/master/docs/components/modules/ROOT/pages/language-component.adoc
https://stackoverflow.com/questions/57104647
复制相似问题