【发布时间】:2016-12-22 12:57:10
【问题描述】:
我有以下骆驼路线设置:
<route id="firstRoute">
<from uri="..." />
<!-- This processor puts a list of items as the out body -->
<process ref="collectItemsProcessor" />
<!-- Now all items should be processed one by one: -->
<split>
<simple>${body}</simple>
<to uri="direct:secondRoute" />
</split>
</route>
<route id="secondRoute">
<from uri="direct:secondRoute" />
<process ref="itemProcessor" />
</route>
在itemProcessor我想统计一下通过把一个属性放入exchange成功处理的item数量:
exchange.setProperty("PROCESSED_ITEMS", exchange.getProperty("PROCESSED_ITEMS", Integer.class) + 1);
由于某种原因,在每次调用处理器时,该属性再次为空。文档说:
交易所还在其整个生命周期内将元数据保存为 使用各种 getProperty(String) 方法访问的属性。
https://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Exchange.html
最初在collectItemsProcessor 中设置属性时,会保留此值。我怀疑每次调用拆分路由都会复制交换,但是我怎样才能真正保留“整个生命周期内的元数据”?
【问题讨论】:
标签: java apache-camel osgi apache-karaf blueprint