camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henryk Konsek <hekon...@gmail.com>
Subject Re: copy of Exchange during Multicast
Date Thu, 14 Jun 2012 11:26:52 GMT
Hi,

> Is there a way to make changes done to the
> header visible in further processing?

Yes. Actually modifications to the headers of the exchanged copied by
multicast are available in the aggregator.

In the example below GroupedExchangeAggregationStrategy will aggregate
two exchanges copied by multicast. And each of the aggregated messages
will got another header set on it (HEADER1 and HEADER2 respectively).

____________________________
CamelContext camelContext = new DefaultCamelContext();
camelContext.addRoutes(new RouteBuilder() {
  @Override
  public void configure() throws Exception {
    from("direct:start").multicast(new GroupedExchangeAggregationStrategy()).
      to("direct:headerModifier1", "direct:headerModifier2").
    end().
    to("log:AGGREGATED");

    from("direct:headerModifier1").process(new Processor() {
      @Override
      public void process(Exchange exchange) throws Exception {
        exchange.getIn().setHeader("KEY1", "VALUE1");
      }
    });

    from("direct:headerModifier2").process(new Processor() {
      @Override
      public void process(Exchange exchange) throws Exception {
        exchange.getIn().setHeader("KEY2", "VALUE2");
      }
    });
  }
});

camelContext.start();
camelContext.createProducerTemplate().sendBody("direct:start", "TestMe!");
____________________________


Kind regards.

-- 
Henryk Konsek
http://henryk-konsek.blogspot.com

Mime
View raw message