java - Camel exchange properties lost during split -
i have following setup of camel routes:
<route id="firstroute"> <from uri="..." /> <!-- processor puts list of items out body --> <process ref="collectitemsprocessor" /> <!-- items should processed 1 one: --> <split> <simple>${body}</simple> <to uri="direct:secondroute" /> </split> </route> <route id="secondroute"> <from uri="direct:secondroute" /> <process ref="itemprocessor" /> </route>
in itemprocessor
want count number of items processed putting property exchange:
exchange.setproperty("processed_items", exchange.getproperty("processed_items", integer.class) + 1);
for reason, on each call processor property null again. documentation says:
the exchange holds meta-data during entire lifetime stored properties accessible using various getproperty(string) methods.
https://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/exchange.html
when setting property in collectitemsprocessor
, value kept. suspect exchange copied each call split route, how can keep "meta-data during entire lifetime"?
split creates new exchange each item. lifetime of exchange covers inside split element.
if want counter of elements processed use property "camelsplitindex". splitter automatically populates property.
Comments
Post a Comment