I have a scenario where I use ExchangeCompleteEvent to print some log.
I have Multicast in my Route as below :-
from("{{route.from}}")
.multicast()
.to("{{route.to1}}")
.to("{{route.to2}}");
The ExchangeCompleteEvent is called 3 times in such case. I think two are for above two .to calls and one is for main exchange.
I want to use it only for main exchange i.e the last call, how can I correlate the ExchangeCompleteEvent with main exchange ?
The child exchanges will have an exchange property stored (key is the field Exchange.CORRELATION_ID
, eg CamelCorrelationId
) which point to their parent exchange id. So you can look for that property to see if its present or not. If not then its the parent exchange.