You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/08/12 16:33:36 UTC

[1/3] camel git commit: CAMEL-6062: Camel properties now support property placeholder

Repository: camel
Updated Branches:
  refs/heads/master 1a594a825 -> 9f245c2de


CAMEL-6062: Camel properties now support property placeholder


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0b9bc105
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0b9bc105
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0b9bc105

Branch: refs/heads/master
Commit: 0b9bc1056375898dd58079d4dd715c7861534c45
Parents: e81a4ca
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Aug 12 16:37:01 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Aug 12 16:41:24 2015 +0200

----------------------------------------------------------------------
 .../camel/component/properties/PropertiesComponentTest.java     | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/0b9bc105/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentTest.java b/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentTest.java
index 96d5723..ad82eec 100644
--- a/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentTest.java
@@ -573,6 +573,9 @@ public class PropertiesComponentTest extends ContextTestSupport {
     }
 
     public void testCamelProperties() throws Exception {
+        context.getProperties().put("foo", "Hello {{cool.name}}");
+        context.getProperties().put("bar", "cool.name");
+
         context.start();
 
         assertEquals("Hello Camel", context.getProperties().get("foo"));
@@ -583,8 +586,6 @@ public class PropertiesComponentTest extends ContextTestSupport {
     protected CamelContext createCamelContext() throws Exception {
         CamelContext context = super.createCamelContext();
         context.addComponent("properties", new PropertiesComponent("classpath:org/apache/camel/component/properties/myproperties.properties"));
-        context.getProperties().put("foo", "Hello {{cool.name}}");
-        context.getProperties().put("bar", "cool.name");
         return context;
     }
 


[3/3] camel git commit: CAMEL-7528: Aggregate EIP now allows to wait and complete all pending exchanges when stopping. For example when using a memory based repository to drain the repo before stopping.

Posted by da...@apache.org.
CAMEL-7528: Aggregate EIP now allows to wait and complete all pending exchanges when stopping. For example when using a memory based repository to drain the repo before stopping.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9f245c2d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9f245c2d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9f245c2d

Branch: refs/heads/master
Commit: 9f245c2deade99cac9a19fdcd20e3d2703fb3158
Parents: 0b9bc10
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Aug 12 16:41:11 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Aug 12 16:41:25 2015 +0200

----------------------------------------------------------------------
 .../SpringAggregateCompleteAllOnStopTest.java   | 33 ++++++++++++++++
 .../SpringAggregateCompleteAllOnStopTest.xml    | 41 ++++++++++++++++++++
 2 files changed, 74 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9f245c2d/components/camel-spring/src/test/java/org/apache/camel/spring/processor/aggregator/SpringAggregateCompleteAllOnStopTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/aggregator/SpringAggregateCompleteAllOnStopTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/aggregator/SpringAggregateCompleteAllOnStopTest.java
new file mode 100644
index 0000000..06b8d8e
--- /dev/null
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/aggregator/SpringAggregateCompleteAllOnStopTest.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.processor.aggregator;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.processor.aggregator.AggregateCompleteAllOnStopTest;
+
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+/**
+ * @version 
+ */
+public class SpringAggregateCompleteAllOnStopTest extends AggregateCompleteAllOnStopTest {
+
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this, "org/apache/camel/spring/processor/aggregator/SpringAggregateCompleteAllOnStopTest.xml");
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/9f245c2d/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aggregator/SpringAggregateCompleteAllOnStopTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aggregator/SpringAggregateCompleteAllOnStopTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aggregator/SpringAggregateCompleteAllOnStopTest.xml
new file mode 100644
index 0000000..48f9601
--- /dev/null
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aggregator/SpringAggregateCompleteAllOnStopTest.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <!-- START SNIPPET: e1 -->
+    <camelContext xmlns="http://camel.apache.org/schema/spring">
+        <route id="foo">
+            <from uri="seda:start"/>
+            <aggregate strategyRef="aggregatorStrategy" completionSize="2" completionTimeout="2000" completeAllOnStop="true">
+                <correlationExpression>
+                    <simple>header.id</simple>
+                </correlationExpression>
+                <to uri="mock:aggregated"/>
+            </aggregate>
+        </route>
+    </camelContext>
+
+    <bean id="aggregatorStrategy" class="org.apache.camel.processor.BodyInAggregatingStrategy"/>
+    <!-- END SNIPPET: e1 -->
+
+</beans>


[2/3] camel git commit: CAMEL-7528: Aggregate EIP now allows to wait and complete all pending exchanges when stopping. For example when using a memory based repository to drain the repo before stopping.

Posted by da...@apache.org.
CAMEL-7528: Aggregate EIP now allows to wait and complete all pending exchanges when stopping. For example when using a memory based repository to drain the repo before stopping.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/e81a4ca6
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e81a4ca6
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e81a4ca6

Branch: refs/heads/master
Commit: e81a4ca686b1db487bc94abc0e287ea8012a0e1a
Parents: 1a594a8
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Aug 12 16:33:59 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Aug 12 16:41:24 2015 +0200

----------------------------------------------------------------------
 .../mbean/ManagedAggregateProcessorMBean.java   |  3 +
 .../camel/impl/DefaultShutdownStrategy.java     | 32 ++++++++---
 .../mbean/ManagedAggregateProcessor.java        |  4 ++
 .../apache/camel/model/AggregateDefinition.java | 29 +++++++++-
 .../processor/aggregate/AggregateProcessor.java | 30 +++++++++-
 .../AggregateCompleteAllOnStopTest.java         | 58 ++++++++++++++++++++
 6 files changed, 147 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/e81a4ca6/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedAggregateProcessorMBean.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedAggregateProcessorMBean.java b/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedAggregateProcessorMBean.java
index 07c1d21..4944422 100644
--- a/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedAggregateProcessorMBean.java
+++ b/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedAggregateProcessorMBean.java
@@ -78,6 +78,9 @@ public interface ManagedAggregateProcessorMBean extends ManagedProcessorMBean {
     @ManagedAttribute(description = "Indicates to complete all current aggregated exchanges when the context is stopped")
     boolean isForceCompletionOnStop();
 
+    @ManagedAttribute(description = "Indicates to wait to complete all current and partial (pending) aggregated exchanges when the context is stopped")
+    boolean isCompleteAllOnStop();
+
     @ManagedAttribute(description = "Number of completed exchanges which are currently in-flight")
     int getInProgressCompleteExchanges();
 

http://git-wip-us.apache.org/repos/asf/camel/blob/e81a4ca6/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java
index eed2235..4d1395e 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java
@@ -595,13 +595,7 @@ public class DefaultShutdownStrategy extends ServiceSupport implements ShutdownS
 
                 for (RouteStartupOrder order : routes) {
                     int inflight = context.getInflightRepository().size(order.getRoute().getId());
-                    for (Consumer consumer : order.getInputs()) {
-                        // include any additional pending exchanges on some consumers which may have internal
-                        // memory queues such as seda
-                        if (consumer instanceof ShutdownAware) {
-                            inflight += ((ShutdownAware) consumer).getPendingExchangesSize();
-                        }
-                    }
+                    inflight += getPendingInflightExchanges(order);
                     if (inflight > 0) {
                         String routeId = order.getRoute().getId();
                         routeInflight.put(routeId, inflight);
@@ -679,6 +673,30 @@ public class DefaultShutdownStrategy extends ServiceSupport implements ShutdownS
     }
 
     /**
+     * Calculates the total number of inflight exchanges for the given route
+     *
+     * @param order the route
+     * @return number of inflight exchanges
+     */
+    protected static int getPendingInflightExchanges(RouteStartupOrder order) {
+        int inflight = 0;
+
+        // the consumer is the 1st service so we always get the consumer
+        // the child services are EIPs in the routes which may also have pending
+        // inflight exchanges (such as the aggregator)
+        for (Service service : order.getServices()) {
+            Set<Service> children = ServiceHelper.getChildServices(service);
+            for (Service child : children) {
+                if (child instanceof ShutdownAware) {
+                    inflight += ((ShutdownAware) child).getPendingExchangesSize();
+                }
+            }
+        }
+
+        return inflight;
+    }
+
+    /**
      * Logs information about the inflight exchanges
      *
      * @param infoLevel <tt>true</tt> to log at INFO level, <tt>false</tt> to log at DEBUG level

http://git-wip-us.apache.org/repos/asf/camel/blob/e81a4ca6/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedAggregateProcessor.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedAggregateProcessor.java b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedAggregateProcessor.java
index a00c63e..e4c167e 100644
--- a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedAggregateProcessor.java
+++ b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedAggregateProcessor.java
@@ -159,6 +159,10 @@ public class ManagedAggregateProcessor extends ManagedProcessor implements Manag
         return processor.isCompletionFromBatchConsumer();
     }
 
+    public boolean isCompleteAllOnStop() {
+        return processor.isCompleteAllOnStop();
+    }
+
     public int getInProgressCompleteExchanges() {
         return processor.getInProgressCompleteExchanges();
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/e81a4ca6/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java b/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java
index 4b89a55..5573842 100644
--- a/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java
@@ -44,7 +44,6 @@ import org.apache.camel.processor.aggregate.OptimisticLockRetryPolicy;
 import org.apache.camel.spi.AggregationRepository;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.RouteContext;
-import org.apache.camel.util.CamelContextHelper;
 import org.apache.camel.util.concurrent.SynchronousExecutorService;
 
 /**
@@ -115,6 +114,8 @@ public class AggregateDefinition extends ProcessorDefinition<AggregateDefinition
     private Boolean discardOnCompletionTimeout;
     @XmlAttribute
     private Boolean forceCompletionOnStop;
+    @XmlAttribute
+    private Boolean completeAllOnStop;
     @XmlTransient
     private AggregateController aggregateController;
     @XmlAttribute
@@ -264,6 +265,9 @@ public class AggregateDefinition extends ProcessorDefinition<AggregateDefinition
         if (getForceCompletionOnStop() != null) {
             answer.setForceCompletionOnStop(getForceCompletionOnStop());
         }
+        if (getCompleteAllOnStop() != null) {
+            answer.setCompleteAllOnStop(getCompleteAllOnStop());
+        }
         if (optimisticLockRetryPolicy == null) {
             if (getOptimisticLockRetryPolicyDefinition() != null) {
                 answer.setOptimisticLockRetryPolicy(getOptimisticLockRetryPolicyDefinition().createOptimisticLockRetryPolicy());
@@ -623,6 +627,14 @@ public class AggregateDefinition extends ProcessorDefinition<AggregateDefinition
         this.forceCompletionOnStop = forceCompletionOnStop;
     }
 
+    public Boolean getCompleteAllOnStop() {
+        return completeAllOnStop;
+    }
+
+    public void setCompleteAllOnStop(Boolean completeAllOnStop) {
+        this.completeAllOnStop = completeAllOnStop;
+    }
+
     public AggregateController getAggregateController() {
         return aggregateController;
     }
@@ -867,6 +879,21 @@ public class AggregateDefinition extends ProcessorDefinition<AggregateDefinition
     }
 
     /**
+     * Indicates to wait to complete all current and partial (pending) aggregated exchanges when the context is stopped.
+     * <p/>
+     * This also means that we will wait for all pending exchanges which are stored in the aggregation repository
+     * to complete so the repository is empty before we can stop.
+     * <p/>
+     * You may want to enable this when using the memory based aggregation repository that is memory based only,
+     * and do not store data on disk. When this option is enabled, then the aggregator is waiting to complete
+     * all those exchanges before its stopped, when stopping CamelContext or the route using it.
+     */
+    public AggregateDefinition completeAllOnStop() {
+        setCompleteAllOnStop(true);
+        return this;
+    }
+
+    /**
      * When aggregated are completed they are being send out of the aggregator.
      * This option indicates whether or not Camel should use a thread pool with multiple threads for concurrency.
      * If no custom thread pool has been specified then Camel creates a default pool with 10 concurrent threads.

http://git-wip-us.apache.org/repos/asf/camel/blob/e81a4ca6/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 4e0dbca..4e3403c 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
@@ -44,6 +44,7 @@ import org.apache.camel.NoSuchEndpointException;
 import org.apache.camel.Predicate;
 import org.apache.camel.Processor;
 import org.apache.camel.ProducerTemplate;
+import org.apache.camel.ShutdownRunningTask;
 import org.apache.camel.TimeoutMap;
 import org.apache.camel.Traceable;
 import org.apache.camel.spi.AggregationRepository;
@@ -51,6 +52,7 @@ import org.apache.camel.spi.ExceptionHandler;
 import org.apache.camel.spi.IdAware;
 import org.apache.camel.spi.OptimisticLockingAggregationRepository;
 import org.apache.camel.spi.RecoverableAggregationRepository;
+import org.apache.camel.spi.ShutdownAware;
 import org.apache.camel.spi.ShutdownPrepared;
 import org.apache.camel.spi.Synchronization;
 import org.apache.camel.support.DefaultTimeoutMap;
@@ -81,7 +83,7 @@ import org.slf4j.LoggerFactory;
  * and older prices are discarded). Another idea is to combine line item messages
  * together into a single invoice message.
  */
-public class AggregateProcessor extends ServiceSupport implements AsyncProcessor, Navigate<Processor>, Traceable, ShutdownPrepared, IdAware {
+public class AggregateProcessor extends ServiceSupport implements AsyncProcessor, Navigate<Processor>, Traceable, ShutdownPrepared, ShutdownAware, IdAware {
 
     public static final String AGGREGATE_TIMEOUT_CHECKER = "AggregateTimeoutChecker";
 
@@ -204,6 +206,7 @@ public class AggregateProcessor extends ServiceSupport implements AsyncProcessor
     private AtomicInteger batchConsumerCounter = new AtomicInteger();
     private boolean discardOnCompletionTimeout;
     private boolean forceCompletionOnStop;
+    private boolean completeAllOnStop;
 
     private ProducerTemplate deadLetterProducerTemplate;
 
@@ -891,6 +894,10 @@ public class AggregateProcessor extends ServiceSupport implements AsyncProcessor
         this.completionFromBatchConsumer = completionFromBatchConsumer;
     }
 
+    public boolean isCompleteAllOnStop() {
+        return completeAllOnStop;
+    }
+
     public ExceptionHandler getExceptionHandler() {
         return exceptionHandler;
     }
@@ -935,6 +942,10 @@ public class AggregateProcessor extends ServiceSupport implements AsyncProcessor
         this.forceCompletionOnStop = forceCompletionOnStop;
     }
 
+    public void setCompleteAllOnStop(boolean completeAllOnStop) {
+        this.completeAllOnStop = completeAllOnStop;
+    }
+
     public void setTimeoutCheckerExecutorService(ScheduledExecutorService timeoutCheckerExecutorService) {
         this.timeoutCheckerExecutorService = timeoutCheckerExecutorService;
     }
@@ -1380,6 +1391,23 @@ public class AggregateProcessor extends ServiceSupport implements AsyncProcessor
         }
     }
 
+    @Override
+    public boolean deferShutdown(ShutdownRunningTask shutdownRunningTask) {
+        // not in use
+        return true;
+    }
+
+    @Override
+    public int getPendingExchangesSize() {
+        if (completeAllOnStop) {
+            // we want to regard all pending exchanges in the repo as inflight
+            Set<String> keys = getAggregationRepository().getKeys();
+            return keys != null ? keys.size() : 0;
+        } else {
+            return 0;
+        }
+    }
+
     private void doForceCompletionOnStop() {
         int expected = forceCompletionOfAllGroups();
 

http://git-wip-us.apache.org/repos/asf/camel/blob/e81a4ca6/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateCompleteAllOnStopTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateCompleteAllOnStopTest.java b/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateCompleteAllOnStopTest.java
new file mode 100644
index 0000000..e2d1405
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateCompleteAllOnStopTest.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor.aggregator;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.processor.BodyInAggregatingStrategy;
+import org.apache.camel.processor.aggregate.MemoryAggregationRepository;
+
+/**
+ * @version
+ */
+public class AggregateCompleteAllOnStopTest extends ContextTestSupport {
+
+    public void testCompleteAllOnStop() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:aggregated");
+        mock.expectedBodiesReceived("A+B", "C");
+
+        // we only send 3, but we get 2 exchanges completed when stopping
+        // as we tell it to complete all on stop
+        template.sendBodyAndHeader("seda:start", "A", "id", "foo");
+        template.sendBodyAndHeader("seda:start", "B", "id", "foo");
+        template.sendBodyAndHeader("seda:start", "C", "id", "foo");
+
+        context.stopRoute("foo");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("seda:start").routeId("foo")
+                        .aggregate(header("id"), new BodyInAggregatingStrategy()).aggregationRepository(new MemoryAggregationRepository())
+                        .completionSize(2).completionTimeout(2000).completeAllOnStop()
+                        .to("mock:aggregated");
+            }
+        };
+    }
+
+}