camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Müller (JIRA) <j...@apache.org>
Subject [jira] [Commented] (CAMEL-4118) Improve the Aggregator to be able to force a flush all aggregated exchanges
Date Wed, 13 Jul 2011 20:51:59 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-4118?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13064832#comment-13064832
] 

Christian Müller commented on CAMEL-4118:
-----------------------------------------

Hey Ben!

I had a quick look on it. Good work. Here are my comments:

Instead of writing:
{code:java}
String completeAllGroups = (String) exchange.getIn().getHeader(Exchange.AGGREGATION_COMPLETE_ALL_GROUPS);
if (completeAllGroups != null && completeAllGroups.equals("true")) {
    forceCompletionOfAllGroups();
    return;
}
{code}

you could write:
{code:java}
Boolean completeAllGroups = exchange.getIn().getHeader(Exchange.AGGREGATION_COMPLETE_ALL_GROUPS,
Boolean.class);
if (completeAllGroups == Boolean.TRUE) {
    forceCompletionOfAllGroups();
    return;
}
{code}
and also benefit from the Camel type converter mechanism (the user can set the header as a
boolean or String value).

AggregateForceCompletionHeaderTest and AggregateForceCompletionOnStopTest didn't check the
header "Exchange.AGGREGATED_COMPLETED_BY" which is/should be set.

Do we need the MyCompletionProcessor for the tests or could we also use the Mock component?

Sorry for being petty... ;-)

> Improve the Aggregator to be able to force a flush all aggregated exchanges
> ---------------------------------------------------------------------------
>
>                 Key: CAMEL-4118
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4118
>             Project: Camel
>          Issue Type: Improvement
>    Affects Versions: 2.7.2
>            Reporter: Christian Müller
>            Assignee: Ben O'Day
>             Fix For: 2.9.0
>
>         Attachments: CAMEL-4097-4118.patch
>
>
> Imagine you process a big file with multiple financial transactions. After splitting
the file into its individual transactions, we send they to an aggregator to group transactions
for the same card/account together. At this time, we don't know how many transactions we have
to group together. Only at the end of processing the input file, we know that we are done.
At this time, we have to instruct the aggregator to "flush all aggregated exchanges".
> A workaround for the time being is, to inject the aggregator also into a bean which is
called after the splitter. This bean can query for all keys with the "getKeys" method and
than send a "flush" exchange to the aggregator (completionPredicate(header("flush"))). However
it will still aggregate that "flush exchange". So take care of that in your custom aggregation
strategy and enable eagerCheckCompletion, so the predicate is checked before aggregating.
> We had a similar question on the user list to "flush all aggregated exchanges" when Camel
shut down.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

Mime
View raw message