Author: davsclaus
Date: Sun Apr 17 14:27:09 2011
New Revision: 1094147
URL: http://svn.apache.org/viewvc?rev=1094147&view=rev
Log:
CAMEL-3878: Stopping a route doesnt stop error handlers as they could
potentialy be shared by other routes.
Added:
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/StopRouteImpactsErrorHandlerTest.java
(with props)
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/StopRouteShouldNotStopContextScopedErrorHandlerIssueTest.java
(with props)
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/StopRouteShouldNotStopRouteScopedErrorHandlerIssueTest.java
(with props)
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java?rev=1094147&r1=1094146&r2=1094147&view=diff
==============================================================================
---
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
(original)
+++
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
Sun Apr 17 14:27:09 2011
@@ -840,7 +840,13 @@ public abstract class RedeliveryErrorHan
@Override
protected void doStop() throws Exception {
- ServiceHelper.stopServices(deadLetter, output, outputAsync);
+ // noop, do not stop any services which we only do when shutting down
+ // as the error handler can be context scoped, and should not stop in
case
+ // a route stops
}
+ @Override
+ protected void doShutdown() throws Exception {
+ ServiceHelper.stopServices(deadLetter, output, outputAsync);
+ }
}
Added:
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/StopRouteImpactsErrorHandlerTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/issues/StopRouteImpactsErrorHandlerTest.java?rev=1094147&view=auto
==============================================================================
---
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/StopRouteImpactsErrorHandlerTest.java
(added)
+++
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/StopRouteImpactsErrorHandlerTest.java
Sun Apr 17 14:27:09 2011
@@ -0,0 +1,90 @@
+/**
+ * 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.issues;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.model.RouteDefinition;
+
+/**
+ *
+ */
+public class StopRouteImpactsErrorHandlerTest extends ContextTestSupport {
+
+ public void testIssue() throws Exception {
+ RouteDefinition testRoute = context.getRouteDefinition("TestRoute");
+ testRoute.adviceWith(context, new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ interceptSendToEndpoint("seda:*")
+ .skipSendToOriginalEndpoint()
+ .to("log:seda")
+ .throwException(new IllegalArgumentException("Forced"));
+ }
+ });
+
+ RouteDefinition smtpRoute = context.getRouteDefinition("smtpRoute");
+ smtpRoute.adviceWith(context, new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ interceptSendToEndpoint("smtp*")
+ .to("log:smtp")
+ .skipSendToOriginalEndpoint()
+ .to("mock:smtp");
+ }
+ });
+
+ // we should fail and end up sending to smtp
+ getMockEndpoint("mock:smtp").expectedMessageCount(1);
+
+ // stopping a route after advice with causes problem with error
handlers
+ context.stopRoute("pollRoute");
+
+ template.sendBody("direct:start", "Hello World");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ context.addComponent("smtp", context.getComponent("mock"));
+
+ errorHandler(deadLetterChannel("direct:emailSupport")
+ .maximumRedeliveries(2)
+ .redeliveryDelay(0));
+
+ from("direct:emailSupport")
+ .routeId("smtpRoute")
+
.errorHandler(deadLetterChannel("log:dead?level=ERROR"))
+ .to("smtp://smtpServer");
+
+
from("timer://someTimer?delay=15000&fixedRate=true&period=5000")
+ .routeId("pollRoute")
+ .to("log:level=INFO");
+
+ from("direct:start")
+ .routeId("TestRoute")
+ .to("seda:foo");
+ }
+ };
+ }
+
+}
+
Propchange:
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/StopRouteImpactsErrorHandlerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/StopRouteImpactsErrorHandlerTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/StopRouteShouldNotStopContextScopedErrorHandlerIssueTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/issues/StopRouteShouldNotStopContextScopedErrorHandlerIssueTest.java?rev=1094147&view=auto
==============================================================================
---
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/StopRouteShouldNotStopContextScopedErrorHandlerIssueTest.java
(added)
+++
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/StopRouteShouldNotStopContextScopedErrorHandlerIssueTest.java
Sun Apr 17 14:27:09 2011
@@ -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.issues;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ *
+ */
+public class StopRouteShouldNotStopContextScopedErrorHandlerIssueTest extends
ContextTestSupport {
+
+ public void testIssue() throws Exception {
+ getMockEndpoint("mock:error").expectedMessageCount(1);
+
+ // stopping foo route, which should not stop context scoped error
handler
+ context.stopRoute("foo");
+
+ template.sendBody("direct:start", "Hello World");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ // use context scoped
+
errorHandler(deadLetterChannel("mock:error").maximumRedeliveries(0));
+
+ from("direct:start").routeId("start")
+ .to("log:start")
+ .throwException(new IllegalArgumentException("Forced"));
+
+ from("direct:foo").routeId("foo")
+ .to("log:foo")
+ .to("mock:foo");
+ }
+ };
+ }
+
+}
+
Propchange:
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/StopRouteShouldNotStopContextScopedErrorHandlerIssueTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/StopRouteShouldNotStopContextScopedErrorHandlerIssueTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/StopRouteShouldNotStopRouteScopedErrorHandlerIssueTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/issues/StopRouteShouldNotStopRouteScopedErrorHandlerIssueTest.java?rev=1094147&view=auto
==============================================================================
---
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/StopRouteShouldNotStopRouteScopedErrorHandlerIssueTest.java
(added)
+++
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/StopRouteShouldNotStopRouteScopedErrorHandlerIssueTest.java
Sun Apr 17 14:27:09 2011
@@ -0,0 +1,57 @@
+/**
+ * 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.issues;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ *
+ */
+public class StopRouteShouldNotStopRouteScopedErrorHandlerIssueTest extends
ContextTestSupport {
+
+ public void testIssue() throws Exception {
+ getMockEndpoint("mock:error").expectedMessageCount(1);
+
+ // stopping foo route, which should not stop context scoped error
handler
+ context.stopRoute("foo");
+
+ template.sendBody("direct:start", "Hello World");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start").routeId("start")
+ // use context scoped
+
.errorHandler(deadLetterChannel("mock:error").maximumRedeliveries(0))
+ .to("log:start")
+ .throwException(new IllegalArgumentException("Forced"));
+
+ from("direct:foo").routeId("foo")
+ .to("log:foo")
+ .to("mock:foo");
+ }
+ };
+ }
+
+}
+
Propchange:
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/StopRouteShouldNotStopRouteScopedErrorHandlerIssueTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/StopRouteShouldNotStopRouteScopedErrorHandlerIssueTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date