Hello,

The problem: we send a message the queue OUT, the message should be sent 2
times to the queue A, and 1 to the queue B, and we should have the following
result:

1. Msg = should be in the queue A, with header invoked=1
2. Msg = should be in the queue B, with header invoked=2
3. Msg = should be in the queue A, with header invoked=3

But we have this :

1. Msg = should be in the queue A, with header invoked=3
2. Msg = should be in the queue B, with header invoked=2
3. Msg = should be in the queue A, with header invoked=3

We use the following route:

<route id="Sending" errorHandlerRef="myDeadLetterChannel">
        <from uri="activemq:queue:OUT" />
        <setHeader headerName="recipients">
                
<simple>activemq://queue:A,activemq://queue:B,activemq://queue:A</simple>
        </setHeader>
        <recipientList parallelProcessing="true" streaming="true"
onPrepareRef="recipientListOnPrepare">
                <header>recipients</header>
        </recipientList>
</route>

package com.company;

import org.apache.camel.Exchange;
import org.apache.camel.Processor;

public class recipientListOnPrepare implements Processor {
        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,

Regards



--
View this message in context: 
http://camel.465427.n5.nabble.com/problem-in-recipientList-with-onPrepareRef-tp5746151.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to