You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Tomasz Prus <to...@gmail.com> on 2008/10/31 09:26:11 UTC

aggregator

Hi,

we try to aggregate messages from different provider, we use multicast
and aggregator but we cannot get it work. We tried it in different
ways but we don't have any idea what we do wrong. Please help:


public void configure() {
       from("jbi:endpoint:http://tel.de/booking/jms/clientRequestReader").multicast().to(FLIGHTS,
HOTELS);

       from(FLIGHTS).filter().xpath("//booking-package-request/flights")
               .to("jbi:endpoint:http://flights.net/JMSProviderService/ypsilonRequestWriter");

       from(HOTELS).filter().xpath("//booking-package-request/hotels")
               .to("jbi:endpoint:http://www.hotels.com/JMSProviderService/gtaRequestWriter");

       from("jbi:endpoint:http://flights.net/jms/flightsConnectorResponseWriter").to("direct:aggregator");
       from("jbi:endpoint:http://www.hotels.com/jms/hotelsConnectorResponseWriter").to("direct:aggregator");


       from("direct:aggregator").aggregator(header("JMSCorrelationID"),
new AggregationStrategy() {

                       @Override
                       public Exchange aggregate(Exchange oldExchange,
Exchange newExchange) {
                               Exchange copy = newExchange.copy();
                       Message newIn = copy.getIn();
                       String oldBody =
oldExchange.getIn().getBody(String.class);
                       String newBody = newIn.getBody(String.class);
                       newIn.setBody(oldBody + "\n" + newBody);
                       return copy;
                       }

       }).
       completedPredicate(header("org.apache.camel.Exchange.AggregatedCount").isEqualTo(3))
       .to("jbi:endpoint:http:/tel.de/booking/clientProviderService/clientProviderEndpoint");