Apache camel - how to "listen" synchronously? Or just send a copy of the exchange?

I have an apache camel route that processes POJOs on the exchange body.

Look at the sequence of lines labeled 1 to 3.

    from("direct:foo")
        .to("direct:doSomething")         // 1 (POJO on the exchange body)
        .to("direct:storeInHazelcast")    // 2 (destroys my pojo! it gets -1)
        .to("direct:doSomethingElse")     // 3 (Where is my POJO??)
    ;

Now I need to use the operation putfor the component hazelcast, which, unfortunately, needs to set the body to -1. A.

    from("direct:storeInHazelcast")
            .setBody(constant(-1))
            .setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.PUT_OPERATION))
            .setHeader(HazelcastConstants.OBJECT_ID, constant(LAST_FLIGHT_UPDATE_SEQ))
            .to("hazelcast:map:MyNumber")
    ;

For the line marked 2, I would like to send a COPY exchange to the route storeInHazelcast.

Firstly, I tried .multicast(), but the exchange body was still screwed (to -1).

        // shouldnt this copy the exchange?
        .multicast().to("direct:storeInHazelcast").end()

Then I tried .wireTap(), which works as a fire and forget (async) mode, but I really need to block it and wait for it to complete. Can you make a wireTap block?

        // this works but I need it to be sync processing (not async)
        .wireTap("direct:storeInHazelcast").end()

, . , multicast() , setBody() storeInHazelcast , .

, , .

. 2.10

+4
4

, , 2 enrich() dsl :

    .enrich("direct:storeInHazelcast", new KeepOriginalAggregationStrategy())

:

public class KeepOriginalAggregationStrategy implements AggregationStrategy {
    @Override
    public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
        return oldExchange;
    }
}

, UseOriginalAggregationStrategy(), , Exchange original DSL.

    .enrich("direct:storeInHazelcast",
        new UseOriginalAggregationStrategy(???, false))

- getExchange() dsl , ( - , , ).

+4

.

from("direct:foo")
    .to("direct:doSomething")         // 1 (POJO on the exchange body)
    .setHeader("old_body", body())    // save body
    .to("direct:storeInHazelcast")    // 2 (destroys my pojo! it gets -1)
    .setBody(header("old_body"))      // RESTORE the body
    .removeHeader("old_body")         // cleanup header
    .to("direct:doSomethingElse")     // 3 (Where is my POJO??)
;

.

+3

,

.enrich("direct:storeInHazelcast", AggregationStrategies.useOriginal())
+1
0