Repository: camel
Updated Branches:
  refs/heads/master beab07afc -> d37ef3577


CAMEL-9355: Reworked throttler implementation to be more performant and use a 
rolling window for time periods which gives a better flow. Thanks to Aaron 
Whiteside for the hard work and patch.


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

Branch: refs/heads/master
Commit: d37ef3577278a85ea2a77c6110921a5e85a73d5e
Parents: da5fa07
Author: Claus Ibsen <davscl...@apache.org>
Authored: Mon Dec 14 09:34:51 2015 +0100
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Mon Dec 14 09:48:34 2015 +0100

----------------------------------------------------------------------
 .../apache/camel/processor/ThrottlerTest.java   |  13 ---
 .../apache/camel/spring/processor/throttler.xml | 117 ++++++++++---------
 2 files changed, 65 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d37ef357/camel-core/src/test/java/org/apache/camel/processor/ThrottlerTest.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/test/java/org/apache/camel/processor/ThrottlerTest.java 
b/camel-core/src/test/java/org/apache/camel/processor/ThrottlerTest.java
index 527c052..c0ae2f5 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/ThrottlerTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/ThrottlerTest.java
@@ -52,16 +52,6 @@ public class ThrottlerTest extends ContextTestSupport {
         resultEndpoint.assertIsSatisfied();
     }
 
-//    public void testNoNestedProcessor() throws Exception {
-//        if (!canTest()) {
-//            return;
-//        }
-//
-//        MockEndpoint resultEndpoint = 
resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
-//        long elapsed = sendMessagesAndAwaitDelivery(MESSAGE_COUNT, 
"direct:noNestedProcessor", MESSAGE_COUNT, resultEndpoint);
-//        assertThrottlerTiming(elapsed, 1, INTERVAL, MESSAGE_COUNT);
-//    }
-    
     public void testSendLotsOfMessagesWithRejectExecution() throws Exception {
         if (!canTest()) {
             return;
@@ -246,9 +236,6 @@ public class ThrottlerTest extends ContextTestSupport {
                 
from("direct:start").throttle(2).timePeriodMillis(10000).rejectExecution(true).to("log:result",
 "mock:result");
 
                 
from("direct:highThrottleRate").throttle(1000).timePeriodMillis(INTERVAL).to("mock:result");
-
-//                
from("direct:noNestedProcessor").throttle(1).timePeriodMillis(INTERVAL).end().to("log:result",
 "mock:result");
-
             }
         };
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/d37ef357/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/throttler.xml
----------------------------------------------------------------------
diff --git 
a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/throttler.xml
 
b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/throttler.xml
index 11f8791..e3fe328 100644
--- 
a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/throttler.xml
+++ 
b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/throttler.xml
@@ -22,62 +22,75 @@
        http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
 
-    <camelContext xmlns="http://camel.apache.org/schema/spring";>
-        <onException>
-            
<exception>org.apache.camel.processor.ThrottlerRejectedExecutionException</exception>
-            <handled><constant>true</constant></handled>
-            <to uri="mock:error"/>
-        </onException>
+  <camelContext xmlns="http://camel.apache.org/schema/spring";>
+    <onException>
+      
<exception>org.apache.camel.processor.ThrottlerRejectedExecutionException</exception>
+      <handled>
+        <constant>true</constant>
+      </handled>
+      <to uri="mock:error"/>
+    </onException>
 
-        <!-- START SNIPPET: example -->
-        <route>
-            <from uri="seda:a"/>
-            <!-- throttle 3 messages per 10 sec -->
-            <throttle timePeriodMillis="10000">
-                <constant>3</constant>
-                <to uri="mock:result"/>
-            </throttle>
-        </route>
-        <!-- END SNIPPET: example -->
+    <!-- START SNIPPET: example -->
+    <route>
+      <from uri="seda:a"/>
+      <!-- throttle 3 messages per 10 sec -->
+      <throttle timePeriodMillis="10000">
+        <constant>3</constant>
+        <to uri="log:result"/>
+        <to uri="mock:result"/>
+      </throttle>
+    </route>
+    <!-- END SNIPPET: example -->
 
-        <route>
-            <from uri="direct:a"/>
-            <!-- throttle 1 messages per 0.5 sec -->
-            <throttle timePeriodMillis="500">
-                <constant>1</constant>
-                <to uri="mock:result"/>
-            </throttle>
-        </route>
+    <route>
+      <from uri="direct:a"/>
+      <!-- throttle 1 messages per 0.5 sec -->
+      <throttle timePeriodMillis="500">
+        <constant>1</constant>
+        <to uri="log:result"/>
+        <to uri="mock:result"/>
+      </throttle>
+    </route>
 
-        <route>
-            <from uri="direct:expressionConstant"/>
-            <throttle timePeriodMillis="500">
-                <constant>1</constant>
-                <to uri="mock:result"/>
-            </throttle>
-        </route>
+    <route>
+      <from uri="direct:expressionConstant"/>
+      <throttle timePeriodMillis="500">
+        <constant>1</constant>
+        <to uri="mock:result"/>
+      </throttle>
+    </route>
 
-        <!-- START SNIPPET: e2 -->
-        <route>
-            <from uri="direct:expressionHeader"/>
-            <throttle timePeriodMillis="500">
-                <!-- use a header to determine how many messages to throttle 
per 0.5 sec -->
-                <header>throttleValue</header>
-                <to uri="mock:result"/>
-            </throttle>
-        </route>
-        <!-- END SNIPPET: e2 -->
-        
-        <route>
-            <from uri="direct:start"/>
-            <!-- throttle 2 messages per 10 sec -->
-            <throttle timePeriodMillis="10000" rejectExecution="true">
-                <constant>2</constant>
-                <to uri="mock:result"/>
-            </throttle>
-            
-        </route>
+    <!-- START SNIPPET: e2 -->
+    <route>
+      <from uri="direct:expressionHeader"/>
+      <throttle timePeriodMillis="500">
+        <!-- use a header to determine how many messages to throttle per 0.5 
sec -->
+        <header>throttleValue</header>
+        <to uri="log:result"/>
+        <to uri="mock:result"/>
+      </throttle>
+    </route>
+    <!-- END SNIPPET: e2 -->
 
-    </camelContext>
+    <route>
+      <from uri="direct:start"/>
+      <!-- throttle 2 messages per 10 sec -->
+      <throttle timePeriodMillis="10000" rejectExecution="true">
+        <constant>2</constant>
+        <to uri="log:result"/>
+        <to uri="mock:result"/>
+      </throttle>
+    </route>
+
+    <route>
+      <from uri="direct:highThrottleRate"/>
+      <throttle timePeriodMillis="500">
+        <constant>1000</constant>
+        <to uri="mock:result"/>
+      </throttle>
+    </route>
+
+  </camelContext>
 
 </beans>

Reply via email to