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 <davscl...@apache.org> Authored: Wed Aug 12 16:41:11 2015 +0200 Committer: Claus Ibsen <davscl...@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>