-
1. Re: Aggregator and NPE
spindipr Aug 17, 2009 8:25 AM (in response to bobyetman)Hi,
Aggregator should contain a component inside it. So, I have placed the File Endpoint component inside the aggregator as shown below.
<to uri="file:///c:/temp/output">
</to>
</aggregator>
</route>
</camelContext>
Thanks,
Sailaja.
-
2. Re: Aggregator and NPE
bobyetman Aug 17, 2009 8:27 AM (in response to bobyetman)So how do you do that in the EIP Diagram editor?
-
3. Re: Aggregator and NPE
spindipr Aug 17, 2009 8:35 AM (in response to bobyetman)-
Aggregator.JPG 15.0 KB
-
-
4. Re: Aggregator and NPE
bobyetman Aug 17, 2009 8:44 AM (in response to spindipr)Okay, gotcha, that's done, no more NPE, but only one of the XLST transforms is making it to the output file. I'm struggling with the correct expression to just re-aggregate the 2 messages back into a single message.
-
5. Re: Aggregator and NPE
spindipr Aug 17, 2009 9:17 AM (in response to bobyetman)The default strategy for aggregator is to take the latest document.
So, if you want to reaggregate the messages then you need to write a custom strategy bean.
I have give an example, which will aggregate incoming bids and return the highest bid.
Source Code logic.
private static class MyAggregationStrategy implements AggregationStrategy {
public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
if (oldExchange == null) {
// the first time we only have the new exchange so it wins the first round
return newExchange;
}
int oldPrice = oldExchange.getIn().getBody(Integer.class);
int newPrice = newExchange.getIn().getBody(Integer.class);
// return the "winner" that has the highest price
return newPrice > oldPrice ? newExchange : oldExchange;
}
}
Thanks,
Sailaja.
-
6. Re: Aggregator and NPE
bobyetman Aug 17, 2009 9:23 AM (in response to spindipr)Thanks, that's what I figured, after doing some more reading on the Camel web site. In the multicast page, I see a ref to BodyOutAggregatingStrategy and BodyInAggregatingStrategy, I may try using those.
-
7. Re: Aggregator and NPE
dinesh_gioe Aug 17, 2009 9:36 AM (in response to bobyetman)Camel website always maintains the information that is supported with the latest camel version. The current camel version is 2.0. But FID 1.2.1 supports 1.5 version of camel. So you may not find some attributes in FID 1.2.1 that are introduced in 2.0 version of camel.
-
8. Re: Aggregator and NPE
bobyetman Aug 17, 2009 10:09 AM (in response to dinesh_gioe)Thanks for the heads up. The BodyInAggregatingStrategy and BodyOutAggregatingStrategy are part of the camel junit tests, I found them in the 1.6.1 version of camel, and have imported them into my EIP project, and they're working fine.