Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

Dysfunction of recipientList with 2 same endpoints in the List (using onPrepareRef)

$
0
0
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

Viewing all articles
Browse latest Browse all 5648

Trending Articles