camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snowbug <>
Subject Why does ExchangeHelper.prepareAggregation modify the in body?
Date Tue, 01 Sep 2009 23:25:25 GMT

When doing aggregation, this code is executed before the actual aggregation:
     * Prepares the exchanges for aggregation.
     * <p/>
     * This implementation will copy the OUT body to the IN body so when you
     * aggregation the body is only in the IN body to avoid confusing end
     * @param oldExchange  the old exchange
     * @param newExchange  the new exchange
    public static void prepareAggregation(Exchange oldExchange, Exchange
newExchange) {
        // copy body/header from OUT to IN
        if (oldExchange != null) {
            if (oldExchange.hasOut()) {

        if (newExchange != null) {
            if (newExchange.hasOut()) {

I have hard time to understand why the IN is overwritten automatically. IN
is the message that comes in and should only be overwritten if I choose to
based on my business logic, not have the framework code to assume this

To make the matter worse, the DefaultExchange.getOut() will automatically
create an empty Message when it is invoked. In other words, if
DefaultExchange.getOut() is called somewhere either in your code or Camel's
code, the OUT message is automatically created, and the hasOut() method will
then be true, and this default empty OUT message is then automatically
copied to the IN. 

If there is a compelling reason shows this behavior is absolutely necessary,
I'd like to create a bug ticket to have it fixed.

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message