Author: davsclaus
Date: Sun Nov 1 14:03:54 2009
New Revision: 831679
URL: http://svn.apache.org/viewvc?rev=831679&view=rev
Log:
CAMEL-1048: Polished example. Renamed scope Total to Context.
Added:
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThrottlingRoutePolicyTest.java
(contents, props changed)
- copied, changed from r831674,
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThrottelingRoutePolicyTest.java
Removed:
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThrottelingRoutePolicyTest.java
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ThrottlingRoutePolicy.java
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThrottlingRoutePolicyTest.java
camel/trunk/examples/camel-example-route-throttling/README.txt
camel/trunk/examples/camel-example-route-throttling/src/main/resources/META-INF/spring/camel-server.xml
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ThrottlingRoutePolicy.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ThrottlingRoutePolicy.java?rev=831679&r1=831678&r2=831679&view=diff
==============================================================================
---
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ThrottlingRoutePolicy.java
(original)
+++
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ThrottlingRoutePolicy.java
Sun Nov 1 14:03:54 2009
@@ -37,7 +37,9 @@
// TODO: need to be JMX enabled as well
- public enum ThrottlingScope { Total, Route }
+ public enum ThrottlingScope {
+ Context, Route
+ }
private final Lock lock = new ReentrantLock();
private ThrottlingScope scope = ThrottlingScope.Route;
@@ -52,7 +54,7 @@
@Override
public String toString() {
- return "ThrottlingRoutePolicyp[" + maxInflightExchanges + " / " +
resumePercentOfMax + "%" + "]";
+ return "ThrottlingRoutePolicy[" + maxInflightExchanges + " / " +
resumePercentOfMax + "% using scope " + scope + "]";
}
public void onExchangeDone(Route route, Exchange exchange) {
@@ -174,7 +176,7 @@
}
private int getSize(Consumer consumer, Exchange exchange) {
- if (scope == ThrottlingScope.Total) {
+ if (scope == ThrottlingScope.Context) {
return exchange.getContext().getInflightRepository().size();
} else {
Endpoint endpoint = consumer.getEndpoint();
Copied:
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThrottlingRoutePolicyTest.java
(from r831674,
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThrottelingRoutePolicyTest.java)
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThrottlingRoutePolicyTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThrottlingRoutePolicyTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThrottelingRoutePolicyTest.java&r1=831674&r2=831679&rev=831679&view=diff
==============================================================================
---
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThrottelingRoutePolicyTest.java
(original)
+++
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThrottlingRoutePolicyTest.java
Sun Nov 1 14:03:54 2009
@@ -23,12 +23,12 @@
/**
* @version $Revision$
*/
-public class ThrottelingRoutePolicyTest extends ContextTestSupport {
+public class ThrottlingRoutePolicyTest extends ContextTestSupport {
private String url = "seda:foo?concurrentConsumers=20";
private int size = 100;
- public void testThrottelingRoutePolicy() throws Exception {
+ public void testThrottlingRoutePolicy() throws Exception {
for (int i = 0; i < size; i++) {
template.sendBody(url, "Message " + i);
}
Propchange:
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThrottlingRoutePolicyTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThrottlingRoutePolicyTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified:
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThrottlingRoutePolicyTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThrottlingRoutePolicyTest.java?rev=831679&r1=831678&r2=831679&view=diff
==============================================================================
---
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThrottlingRoutePolicyTest.java
(original)
+++
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringThrottlingRoutePolicyTest.java
Sun Nov 1 14:03:54 2009
@@ -17,13 +17,13 @@
package org.apache.camel.spring.processor;
import org.apache.camel.CamelContext;
-import org.apache.camel.processor.ThrottelingRoutePolicyTest;
+import org.apache.camel.processor.ThrottlingRoutePolicyTest;
import static
org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
/**
* @version $Revision$
*/
-public class SpringThrottlingRoutePolicyTest extends
ThrottelingRoutePolicyTest {
+public class SpringThrottlingRoutePolicyTest extends ThrottlingRoutePolicyTest
{
protected CamelContext createCamelContext() throws Exception {
return createSpringCamelContext(this,
"org/apache/camel/spring/processor/ThrottlingRoutePolicyTest.xml");
Modified: camel/trunk/examples/camel-example-route-throttling/README.txt
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-route-throttling/README.txt?rev=831679&r1=831678&r2=831679&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-route-throttling/README.txt (original)
+++ camel/trunk/examples/camel-example-route-throttling/README.txt Sun Nov 1
14:03:54 2009
@@ -12,6 +12,10 @@
You can see on the server it should log in the console how it adjust the
throttling dynamically.
+The goal of this example is to illustrate that Camel throttles the JMS queue
+to be on same pace with the rest of the Camel routing. When running the example
+you should observe that the JMS route and the SEDA route completes nearly in
sync.
+
For the latest & greatest documentation on how to use this example please see:
http://camel.apache.org/examples.html
Modified:
camel/trunk/examples/camel-example-route-throttling/src/main/resources/META-INF/spring/camel-server.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-route-throttling/src/main/resources/META-INF/spring/camel-server.xml?rev=831679&r1=831678&r2=831679&view=diff
==============================================================================
---
camel/trunk/examples/camel-example-route-throttling/src/main/resources/META-INF/spring/camel-server.xml
(original)
+++
camel/trunk/examples/camel-example-route-throttling/src/main/resources/META-INF/spring/camel-server.xml
Sun Nov 1 14:03:54 2009
@@ -41,17 +41,27 @@
</bean>
<bean id="myPolicy" class="org.apache.camel.impl.ThrottlingRoutePolicy">
- <property name="scope" value="Route"/>
- <property name="maxInflightExchanges" value="80"/>
- <property name="loggingLevel" value="INFO"/>
+ <property name="scope" value="Context"/>
+ <property name="maxInflightExchanges" value="30"/>
+ <property name="resumePercentOfMax" value="10"/>
+ <property name="loggingLevel" value="WARN"/>
</bean>
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+
+ <endpoint uri="seda:inbox?concurrentConsumers=40&size=25000"
id="bar"/>
+
<route routePolicyRef="myPolicy">
<from uri="jms:queue:inbox?concurrentConsumers=100"/>
<transacted/>
+ <to uri="log:+++JMS +++?groupSize=100"/>
+ <to ref="bar"/>
+ </route>
+
+ <route>
+ <from ref="bar"/>
<delay><constant>100</constant></delay>
- <to uri="log:inbox?groupSize=50"/>
+ <to uri="log:+++SEDA+++?groupSize=100"/>
</route>
</camelContext>