Hi

For every exchange you loop but don't break, since you match "direct://A"
twice, the 1st header is overwritten.
Can you tell us more about what you're trying to do?
If it's just to track how many times the endpoint is invoked, there are
other ways.

Taariq


On Sun, Jan 19, 2014 at 2:32 AM, ABouchama <tit...@yahoo.fr> wrote:

> Dear all,
>
> [project available in this link with unit test :
> https://github.com/abouchama/camel_recipientList
> <https://github.com/abouchama/camel_recipientList>   ]
>
> The problem: we send a message the direct=recipientList, the message should
> be sent 2 times to the direct A, and 1 to the direct B, and we should have
> the following result (the project in the attach of this ticket with unit
> test ):
>
> 1. Msg = should be in the direct A, with header invoked=0
> 2. Msg = should be in the direct B, with header invoked=1
> 3. Msg = should be in the direct A, with header invoked=2
>
> But we have this :
>
> 1. Msg = should be in the direct A, with header invoked=2
> 2. Msg = should be in the direct B, with header invoked=1
> 3. Msg = should be in the direct A, with header invoked=2
>
> We use the following route:
>
>                 <route id="recipientList">
>                         <from uri="direct:recipientList" />
>                         <setHeader headerName="recipients">
>
> <simple>direct://A,direct://B,direct://A</simple>
>                         </setHeader>
>                         <recipientList parallelProcessing="true"
> streaming="true"
>                                 onPrepareRef="recipientListOnPrepare">
>                                 <header>recipients</header>
>                         </recipientList>
>                 </route>
>
> With the following class:
>
> public void process(Exchange exchange) throws Exception {
>                 String recipients = (String)
> exchange.getIn().getHeader("recipients");
>                 String toEndpoint = (String)
> exchange.getProperty(Exchange.TO_ENDPOINT);
>
>                 String[] Recipients = recipients.split(",");
>
>                 for (int i = 0; i < Recipients.length; i++) {
>                         if (toEndpoint.equalsIgnoreCase(Recipients[i])) {
>                                 exchange.getIn().setHeader("invoked", i);
>                         }
>
>                 }
>
>
> Thanks in advance
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Dysfunction-of-recipientList-with-2-same-endpoints-in-the-List-using-onPrepareRef-tp5746210.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Reply via email to