camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [CONF] Apache Camel > Route Throttling Example
Date Mon, 02 Nov 2009 12:38:00 GMT
    <base href="">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="">Route
Throttling Example</a></h2>
    <h4>Page  <b>added</b> by             <a href="">Claus
    <div class="notificationGreySide">
         <h2><a name="RouteThrottlingExample-RouteThrottlingExample"></a>Route
Throttling Example</h2>
<p><b>Available as of Camel 2.1</b></p>

<h3><a name="RouteThrottlingExample-About"></a>About</h3>
<p>This example shows how to use the new feature <a href="/confluence/display/CAMEL/RoutePolicy"
title="RoutePolicy">RoutePolicy</a> to dynamically at runtime to throttle routes
based on metrics gathered by the current number of inflight exchanges. </p>

<p>What it means is that Camel will dynamic throttle the routes based on the flow of
messages being processed at runtime.</p>

<p>The example have 3 routes where as two of the routes are input routes, and the last
is the processing route<br/>
1. route1: from("jms") - input from a JMS queue<br/>
2. route2: from("file") - input from a file folder<br/>
3. route3: from("seda") - processing of the input messages, this one simulates CPU work by
delaying the messages 100 mills.</p>

<h3><a name="RouteThrottlingExample-Howitworks"></a>How it works</h3>
<p>When the example runs we have a dependency from the routes as follows:</p>
	<li>route1 -&gt; route3</li>
	<li>route2 -&gt; route3</li>

<p>What the example demonstrates is that Camel is capable of dynamic throttling route1
and route2 based on the total flow of messages. At runtime Camel gathers the current inflight
exchanges in a registry which is used for metrics.</p>

<p>So when the flow is going <em>too fast</em> then the <a href="/confluence/display/CAMEL/RoutePolicy"
title="RoutePolicy">RoutePolicy</a> kicks in and <tt>suspends</tt> route1
and/or route2. The current inflight exchanges will continue to be processed and when we are
below a <em>threshold</em> then the <a href="/confluence/display/CAMEL/RoutePolicy"
title="RoutePolicy">RoutePolicy</a> kicks in again and <tt>resumes</tt>
route1 and/or route2.</p>

<p>Camel provides the throttling policy in the <tt>org.apache.camel.impl.ThrottlingRoutePolicy</tt>.</p>

<h3><a name="RouteThrottlingExample-Howtorun"></a>How to run</h3>
<p>The example has 3 maven goals to run the example</p>

<p><tt>mvn compile exec:java -PCamelServer</tt> - starts the Camel Server
which contains the 3 routes and where you should check its log output for how it goes.</p>

<p><tt>mvn compile exec:java -PCamelClient</tt> - is a client that sends
10000 JMS messages to the JMS broker which is consumed by route1. The Server must be started

<p><tt>mvn compile exec:java -PCamelFileClient</tt> - is a client that creates
5000 files that are consumed by route2. The server may be started beforehand, but its not

<p>So at first you start the server. Then at any time you can run a client at will.
For example you can run the JMS client and let it run to completion at the server. You can
see at the server console logging that it reports the progress. And at sometime it will reach
10000 messages processed. You can then start the client again if you like.</p>

<p>You can also start the other client to create the files which then let the example
be a bit more complicated as we have concurrent processing of JMS messages and files at the
same time. And where as both of these should be dynamic throttled so we wont go <em>too

<h3><a name="RouteThrottlingExample-Howtochange"></a>How to change</h3>
<p>You can check the file <tt>src/main/resources/META-INF/spring/camel-server.xml</tt>
file where you can see the configuration of the dynamic throttler. By default its configured

<p>TODO: snippet</p>

<p>You can then change this and restart the server to see the changes in effect.</p>

<h3><a name="RouteThrottlingExample-JMXmanagement"></a>JMX management</h3>

<h3><a name="RouteThrottlingExample-SeeAlso"></a>See Also</h3>
<ul class="alternate" type="square">
	<li><a href="/confluence/display/CAMEL/Examples" title="Examples">Examples</a></li>
	<li><a href="/confluence/display/CAMEL/RoutePolicy" title="RoutePolicy">RoutePolicy</a></li>

    <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href=""
class="grey">Change Notification Preferences</a>
       <a href="">View
       <a href=";showCommentArea=true#addcomment">Add

View raw message