Java Code Examples for org.apache.camel.Exchange.copy()

The following are Jave code examples for showing how to use copy() of the org.apache.camel.Exchange class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: ipf-flow-manager   File: Splitter.java   Source Code and License Vote up 6 votes
@Override
protected void finalizeAggregate(Exchange origExchange, Exchange aggregate) {
    ManagedMessage origMessage = new PlatformMessage(origExchange);
    SplitHistory origHistory = origMessage.getSplitHistory();
    
    // The aggregate needs to be copied to ensure that we can change it
    // without affecting the input into the destination processor of the
    // splitter.
    if (aggregate != null){
        Exchange copiedAggregate = aggregate.copy();
        ManagedMessage message = new PlatformMessage(copiedAggregate);
        SplitHistory aggregateHistory = message.getSplitHistory();
        if (!aggregateHistory.equals(origHistory)) {
            message.setSplitHistory(origHistory);
        }
        super.finalizeAggregate(origExchange, copiedAggregate);
    } else {
        super.finalizeAggregate(origExchange, aggregate);
    }
    
}
 
Example 2
Project: ipf-flow-manager   File: CoreSplitter.java   Source Code and License Vote up 5 votes
private Exchange processResult(final Exchange origExchange,
                               final SplitIndex index,
                               final Object splitPart) throws Exception {

    final Exchange subExchange = origExchange.copy();

    Message message = subExchange.getIn();
    message.setBody(splitPart);
    finalizeSubExchange(origExchange, subExchange, index);

    super.processNext(subExchange);
    return subExchange;
}