camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAMEL-12125) Add keepOpen to the ThrottlingExceptionRoutePolicy circuit breaker
Date Sat, 06 Jan 2018 12:08:00 GMT

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

ASF GitHub Bot commented on CAMEL-12125:
----------------------------------------

davsclaus commented on a change in pull request #2165: [CAMEL-12125] add keepOpen to endpoint
circuit breaker
URL: https://github.com/apache/camel/pull/2165#discussion_r160024313
 
 

 ##########
 File path: camel-core/src/test/java/org/apache/camel/processor/ThrottlingExceptionRoutePolicyKeepOpenOnInitTest.java
 ##########
 @@ -0,0 +1,98 @@
+package org.apache.camel.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.ThrottlingExceptionRoutePolicy;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ThrottlingExceptionRoutePolicyKeepOpenOnInitTest extends ContextTestSupport
{
+
+    private String url = "seda:foo?concurrentConsumers=20";
+    private MockEndpoint result;
+    private int size = 5;
+
+    private ThrottlingExceptionRoutePolicy policy;
+
+    @Override
+    @Before
+    public void setUp() throws Exception {
+        this.createPolicy();
+
+        super.setUp();
+        this.setUseRouteBuilder(true);
+        result = getMockEndpoint("mock:result");
+        context.getShutdownStrategy().setTimeout(1);
+    }
+
+    protected void createPolicy() {
+        int threshold = 2;
+        long failureWindow = 30;
+        long halfOpenAfter = 1000;
+        boolean keepOpen = true;
+        policy = new ThrottlingExceptionRoutePolicy(threshold, failureWindow, halfOpenAfter,
null, keepOpen);
+    }
+
+    @Test
+    public void testThrottlingRoutePolicyStartWithAlwaysOpenOn() throws Exception {
+
+        log.debug("---- sending some messages");
+        for (int i = 0; i < size; i++) {
+            template.sendBody(url, "Message " + i);
+            Thread.sleep(3);
+        }
+
+        // gives time for policy half open check to run every second
+        // and should not close b/c keepOpen is true
+        Thread.sleep(2000);
 
 Review comment:
   Is there a way to not sleep for 2 seconds, eg this test takes 5+ seconds to run, and it
would be nice with fast unit tests of camel-core. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Add keepOpen to the ThrottlingExceptionRoutePolicy circuit breaker
> ------------------------------------------------------------------
>
>                 Key: CAMEL-12125
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12125
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.19.0
>            Reporter: Mike Barlotta
>            Priority: Minor
>
> a useful addition to the endpoint circuit breaker (see CAMEL-10718) would be the ability
to force it into the open state so that it suspends consuming even if there are no exceptions.

> this would function similar to the Netflix Hystrix forceOpen
> https://github.com/Netflix/Hystrix/wiki/Configuration#circuitBreaker.forceOpen
> Willing to submit a PR



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message