Repository: camel Updated Branches: refs/heads/master 4e7ec8f79 -> 55b2bf86e
CAMEL-8423: Moved the key to exchange where all the other related keys are. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/55b2bf86 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/55b2bf86 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/55b2bf86 Branch: refs/heads/master Commit: 55b2bf86ea1d3fa041c799c562bec2990facdfdd Parents: 4e7ec8f Author: Claus Ibsen <davscl...@apache.org> Authored: Wed Mar 4 06:54:17 2015 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Wed Mar 4 06:54:17 2015 +0100 ---------------------------------------------------------------------- camel-core/src/main/java/org/apache/camel/Exchange.java | 1 + .../apache/camel/processor/aggregate/AggregateProcessor.java | 7 ++++--- .../camel/processor/aggregate/AggregationStrategy.java | 7 ------- .../AggregationStrategyCompleteByPropertyTest.java | 8 ++++++-- 4 files changed, 11 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/55b2bf86/camel-core/src/main/java/org/apache/camel/Exchange.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/Exchange.java b/camel-core/src/main/java/org/apache/camel/Exchange.java index 42a7632..9f21f15 100644 --- a/camel-core/src/main/java/org/apache/camel/Exchange.java +++ b/camel-core/src/main/java/org/apache/camel/Exchange.java @@ -78,6 +78,7 @@ public interface Exchange { String AGGREGATED_COMPLETED_BY = "CamelAggregatedCompletedBy"; String AGGREGATED_CORRELATION_KEY = "CamelAggregatedCorrelationKey"; String AGGREGATION_STRATEGY = "CamelAggregationStrategy"; + String AGGREGATION_COMPLETE_CURRENT_GROUP = "CamelAggregationCompleteCurrentGroup"; String AGGREGATION_COMPLETE_ALL_GROUPS = "CamelAggregationCompleteAllGroups"; String AGGREGATION_COMPLETE_ALL_GROUPS_INCLUSIVE = "CamelAggregationCompleteAllGroupsInclusive"; String ASYNC_WAIT = "CamelAsyncWait"; http://git-wip-us.apache.org/repos/asf/camel/blob/55b2bf86/camel-core/src/main/java/org/apache/camel/processor/aggregate/AggregateProcessor.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/processor/aggregate/AggregateProcessor.java b/camel-core/src/main/java/org/apache/camel/processor/aggregate/AggregateProcessor.java index a1fa0ed..e30feb8 100644 --- a/camel-core/src/main/java/org/apache/camel/processor/aggregate/AggregateProcessor.java +++ b/camel-core/src/main/java/org/apache/camel/processor/aggregate/AggregateProcessor.java @@ -405,9 +405,6 @@ public class AggregateProcessor extends ServiceSupport implements AsyncProcessor * @return <tt>null</tt> if not completed, otherwise a String with the type that triggered the completion */ protected String isCompleted(String key, Exchange exchange) { - if (exchange.getProperty(AggregationStrategy.IS_COMPLETE) == Boolean.TRUE) { - return "strategy"; - } // batch consumer completion must always run first if (isCompletionFromBatchConsumer()) { batchConsumerCorrelationKeys.add(key); @@ -420,6 +417,10 @@ public class AggregateProcessor extends ServiceSupport implements AsyncProcessor } } + if (exchange.getProperty(Exchange.AGGREGATION_COMPLETE_CURRENT_GROUP, false, boolean.class)) { + return "strategy"; + } + if (getCompletionPredicate() != null) { boolean answer = getCompletionPredicate().matches(exchange); if (answer) { http://git-wip-us.apache.org/repos/asf/camel/blob/55b2bf86/camel-core/src/main/java/org/apache/camel/processor/aggregate/AggregationStrategy.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/processor/aggregate/AggregationStrategy.java b/camel-core/src/main/java/org/apache/camel/processor/aggregate/AggregationStrategy.java index bf5f5be..e8cd90f 100644 --- a/camel-core/src/main/java/org/apache/camel/processor/aggregate/AggregationStrategy.java +++ b/camel-core/src/main/java/org/apache/camel/processor/aggregate/AggregationStrategy.java @@ -47,13 +47,6 @@ public interface AggregationStrategy { // TODO: In Camel 3.0 we should move this to org.apache.camel package /** - * During the call to {@link #aggregate(org.apache.camel.Exchange, org.apache.camel.Exchange) aggregate}, if the - * AggregationStrategy determines that the aggregation is complete and should be sent on (example: size limits exceeded), - * then it can set the property on the returned Exchange to Boolean.TRUE to mark the aggregation as complete. - */ - String IS_COMPLETE = "AggregationStrategy.IS_COMPLETE"; - - /** * Aggregates an old and new exchange together to create a single combined exchange * * @param oldExchange the oldest exchange (is <tt>null</tt> on first aggregation as we only have the new exchange) http://git-wip-us.apache.org/repos/asf/camel/blob/55b2bf86/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregationStrategyCompleteByPropertyTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregationStrategyCompleteByPropertyTest.java b/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregationStrategyCompleteByPropertyTest.java index a3b5933..1c470e1 100644 --- a/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregationStrategyCompleteByPropertyTest.java +++ b/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregationStrategyCompleteByPropertyTest.java @@ -19,6 +19,7 @@ package org.apache.camel.processor.aggregator; import org.apache.camel.ContextTestSupport; import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.processor.aggregate.AggregationStrategy; /** @@ -27,7 +28,10 @@ import org.apache.camel.processor.aggregate.AggregationStrategy; public class AggregationStrategyCompleteByPropertyTest extends ContextTestSupport { public void testAggregateCompletionAware() throws Exception { - getMockEndpoint("mock:aggregated").expectedBodiesReceived("A+B+C", "X+Y+ZZZZ"); + MockEndpoint result = getMockEndpoint("mock:aggregated"); + result.expectedBodiesReceived("A+B+C", "X+Y+ZZZZ"); + result.message(0).exchangeProperty(Exchange.AGGREGATED_COMPLETED_BY).isEqualTo("strategy"); + result.message(1).exchangeProperty(Exchange.AGGREGATED_COMPLETED_BY).isEqualTo("strategy"); template.sendBodyAndHeader("direct:start", "A", "id", 123); template.sendBodyAndHeader("direct:start", "B", "id", 123); @@ -63,7 +67,7 @@ public class AggregationStrategyCompleteByPropertyTest extends ContextTestSuppor + newExchange.getIn().getBody(String.class); oldExchange.getIn().setBody(body); if (body.length() >= 5) { - oldExchange.setProperty(AggregationStrategy.IS_COMPLETE, true); + oldExchange.setProperty(Exchange.AGGREGATION_COMPLETE_CURRENT_GROUP, true); } return oldExchange; }