camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ABouchama <tit...@yahoo.Fr>
Subject Dysfunction of recipientList with 2 same endpoints in the List (using onPrepareRef)
Date Sun, 19 Jan 2014 00:32:59 GMT
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.

Mime
View raw message