You shouldn't have to do the counting yourself - Camel is doing that for you:

Exchange properties: The following properties are set on each Exchange that are 
split:

CamelSplitIndex  (int)
A split counter that increases for each Exchange being split. The counter 
starts from 0.

CamelSplitSize (int)
The total number of Exchanges that was splitted. This header is not applied for 
stream based splitting. From Camel 2.9 onwards this header is also set in 
stream based splitting, but only on the completed Exchange.

CamelSplitComplete (Boolean)
Camel 2.4: Whether or not this Exchange is the last. 

(from http://camel.apache.org/splitter.html)

Hope that helps,
Kai


> -----Original Message-----
> From: Scisci [mailto:ferioli.mi...@gmail.com]
> Sent: Monday, November 16, 2015 9:14 AM
> To: users@camel.apache.org
> Subject: AggregatinStrategy on split never stop
> 
> Hi,
> I've a problem with a split and custom aggregationStrateqy.
> I've to count the items that were split.
> This in my AggreagationSt egy
> 
> public class Item_AggregationStrategy implements AggregationStrategy{
> 
>       private static final Logger LOGGER =
> Logger.getLogger(Item_AggregationStrategy.class);
> 
> 
>       @Override
>       public Exchange aggregate(Exchange oldExchange, Exchange
> newExchange) {
>               LOGGER.info("Sono in Item_AggregationStrategy");
> 
>                if (oldExchange == null)
>                {
>                   return newExchange;
>            }
> 
> 
>               Integer numero_items =
> oldExchange.getIn().getHeader("Numero_Items",
> Integer.class);
>               LOGGER.info("Numero Items: " + numero_items);
>               numero_items++;
>               LOGGER.info("Numero Items 2: " + numero_items);
> 
>               newExchange.getIn().setHeader("Numero_Items",
> numero_items);
> 
>               return newExchange;
>       }
> 
> and this is part of my route:
> 
> <process ref="Cancellazione_Tabelle"/>
>                               <split streaming="true"
> strategyRef="Item_Aggregator" >-->
>                                       <tokenize token="Item" xml="true"
> inheritNamespaceTagName="ag_01:Accpos"/>
>                                       <to uri="direct:Convert_Accpos"/>
>                       </split>
>                       <log message="Numero_Items dopo lo split:
> ${header.Numero_Items}"/>
> 
> it's look like tha the aggregator never end...
> How to set a timeout like completionTimeout on aggregator ?
> 
> Thanks
> Mirko
> 
> 
> 
> 
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/AggregatinStrategy-on-split-never-stop-
> tp5773905.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to