camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Block <>
Subject Re: Implementing a counter in XML DSL and Simple
Date Sat, 16 May 2015 05:14:31 GMT

Each exchange executing within the split is independent of each other. Incrementing the value
of a header on one split exchange will have no effect on another. 

If you want to get the number of split items, it is available after the split in Exchange.CamelSplitSize

In addition, take a look at the other headers available within the splitter component [1]
documentation for more options available

- Andy

[1] -

Andrew Block

On May 15, 2015 at 11:50:51 AM, Davis, Daniel ( wrote:

From Claus' 2011 blog I tried to implement a counter but I cannot get it
to work inside a splitter (I need a count of only a subset of items).

The example code is:

<setHeader header="myCounter">

By itself this code fails because myCounter is not a number.

So I initialized it outside the Split but inside the same route.

<setHeader headerName="ImageIndex">
<simple resultType="java.lang.Integer">0</simple>

No exceptions but it increments once and only once inside the split. So
I simplified and removed the initialization.

<setHeader headerName="ImageIndex">
<simple resultType="java.lang.Integer">${header.ImageIndex}++</simple>

No exceptions but it also increments once and only once inside the
split. It seems like it is grabbing the original header value off the
exchange each time and incrementing it.

Does anyone see what I am missing? Is split behavior in some way
causing this?

Dan Davis

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message