Answering my own question:
 from("seda:anotherOne")
                .log("Received message from anotherOne: ${body}").split(body
()).parallelProcessing()
                .process(exchange -> {
                    Object body = exchange.getIn().getBody();
                    exchange.getIn().setBody(body instanceof Exchange ?
((Exchange) body).getIn().getBody() : body);
                    Map<String, Object> originalHeaders = new HashMap<>(
body instanceof Exchange ? ((Exchange) body).getIn().getHeaders(): exchange.
getIn().getHeaders());
                    exchange.getIn().setHeaders(originalHeaders);
                })
                .log("2 ${headers} ${body}")



Is there any other way of doing this ?


On Sun, Mar 30, 2025 at 7:38 PM Chirag <chirag.sangh...@gmail.com> wrote:

> Hello Camel riders
>
> Here is my sample route.
>
>   from("timer:java?period=1000")
>                 .setProperty("uuid").simple("${exchangeId}")
>                 .setBody()
>                 .simple("Hello Camel from ${uuid} at
> ${date:now:yyyy-MM-dd HH:mm:ss.SSS}")
>                 
> .setHeader("CamelGooglePubsubAttributes").mvel("['key1':'value1',
> 'key2':'${uuid}']")
>                 .to("seda:startAggr");
>
>         from("seda:startAggr")
>
>                 // aggregates all using the same expression and group the
>                 // exchanges, so we get one single exchange containing all
>                 // the others
>                .aggregate(new GroupedExchangeAggregationStrategy()).
> constant(true).completionSize(5)
>             //.aggregate(new
> GroupedBodyAggregationStrategy()).constant(true).completionSize(5)
>                 .log("aggregated ${body}")
>                 .log("Properties: ${exchangeProperty.CamelAggregatedSize}"
> )
>                 .to(
> "google-pubsub:test-project:test-topic?serviceAccountKey=file:///C:/work/camel-demos//testaggr//camel-pubsub-component.json"
> )
>                 .to("seda:anotherOne").end();
>
>
> This is working from Camel to Endpoint - 5 exchanges are being grouped and
> I can see 5 payloads written into Google PubSub.
>
> normally, when an endpoint is invoked, it would return specific responses.
> How does one go about accessing responses for a grouped exchange?
>

Reply via email to