camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From santhosh <ramukhsohtna...@gmail.com>
Subject Re: Camel receipient list with interceptor
Date Wed, 20 Mar 2013 20:35:33 GMT
I will answer this question myself .You can find the endpoint which the
exchange is used by using

exchange.getProperty("CamelToEndpoint") .



To answer the overall question - how to manipulate the message in
recipient/multicast according to endpoint keeping in mind the endpoint list
will be created dynamically at runtime.What it means is we would know which
endpoints the message needs to be mulitcasted only at runtime and before it
gets sent we need to perform endpoint specific message manipulation.

					<recipientList parallelProcessing="true" streaming="true"
						id="recipientList" strategyRef="StringAggregationStrategy"
						timeout="2500" onPrepareRef="CustomExchangeMessage"  delimiter=","
ignoreInvalidEndpoints="true">

						<header>endpointList</header>

</recipientList>

The below class is just an idea out of my mind.in real use case the
recipient list will be populated dynamically and the exchange body
manipulation will be dynamic.I dont know if this is the recommended way but
i think it  will work .Please let me know if see any obvious problems

public class  CustomExchangeMessage  implements Processor {
	  public void process(Exchange exchange) throws Exception {
	        String body = exchange.getIn().getBody(String.class);
                String toEndpoint=exchange.getProperty("CamelToEndpoint");
	         //this is a simple if now .but this will be where the dynamic part
willl kick in.        
                 if(toEndpoint.equalsIgnoreCase("A"))
                 {
                           //manipulate the body for endpoint A 
                 }
	         if(toEndpoint.equalsIgnoreCase("B"))
                 {
                         //manipulate the body for endpoint B
                 }

	        
	    }

}


This question has been answered and can be closed.




--
View this message in context: http://camel.465427.n5.nabble.com/Camel-receipient-list-with-interceptor-tp5729462p5729568.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message