camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > CronScheduledRoutePolicy
Date Fri, 08 Jul 2011 13:06:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CAMEL/CronScheduledRoutePolicy">CronScheduledRoutePolicy</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~davsclaus">Claus
Ibsen</a>
    </h4>
        <br/>
                         <h4>Changes (8)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-unchanged" >h2. CronScheduledRoutePolicy <br>
<br></td></tr>
            <tr><td class="diff-changed-lines" >CronScheduledRoutePolicy is a
<span class="diff-changed-words"><span class="diff-added-chars"style="background-color:
#dfd;">[</span>ScheduledRoutePolicy<span class="diff-added-chars"style="background-color:
#dfd;">]</span></span> that facilitates route activation, de-activation, suspension
and resumption of routes based on a <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">Quartz
CronTrigger.</span> <span class="diff-added-words"style="background-color: #dfd;">[Quartz]
{{CronTrigger}}.</span> <br></td></tr>
            <tr><td class="diff-unchanged" > <br>Maven users will need to
add a camel-quartz dependency to their {{pom.xml}} to avail this capability. <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >h3. How it works <br> <br></td></tr>
            <tr><td class="diff-unchanged" >In order to use a [CronScheduledRoutePolicy]
it is necessary to instantiate an object of the type {{org.apache.camel.routepolicy.quartz.CronScheduledRoutePolicy}}.
<br></td></tr>
            <tr><td class="diff-unchanged" > <br>In order to perform a route
operation at a given time the following information must be provided. <br> <br>*
Starting a route <br></td></tr>
            <tr><td class="diff-unchanged" >|| Parameter Name || Type || Default
Value || Description || <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">||</span>
<span class="diff-added-words"style="background-color: #dfd;">|</span> routeStartTime
<span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">||</span>
<span class="diff-added-words"style="background-color: #dfd;">|</span> String
<span class="diff-changed-words">|<span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">|</span>
|<span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">|</span></span>
the initial scheduled Date and time as a Cron Expression for route start <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">||</span>
<span class="diff-added-words"style="background-color: #dfd;">|</span> <br></td></tr>
            <tr><td class="diff-unchanged" > <br>* Stopping a route  <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">||
Parameter Name || Type || Default Value || Description || <br>| routeStopTime | String
| | the initial scheduled Date and time as a Cron Expression for route stop | <br>|
routeStopGracePeriod | int | 10 seconds | the time period to wait before initiating graceful
route stop | <br>| routeStopTimeUnit | long | TimeUnit.MILLISECONDS | the time unit
for the grace period expressed as java.util.concurrent.TimeUnit | <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">||
routeStopTime || String || || the initial scheduled Date and time as a Cron Expression for
route stop || <br>|| routeStopGracePeriod || int || 10 seconds || the time period to
wait before initiating graceful route stop || <br>|| routeStopTimeUnit || long || TimeUnit.MILLISECONDS
|| the time unit for the grace period expressed as java.util.concurrent.TimeUnit || <br>
<br></td></tr>
            <tr><td class="diff-unchanged" >* Suspending a route <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">||
Parameter Name || Type || Default Value || Description || <br>| routeSuspendTime | String
| | the initial scheduled Date and time as a Cron Expression for route suspension | <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">||
routeSuspendTime || String || || the initial scheduled Date and time as a Cron Expression
for route suspension || <br> <br> <br></td></tr>
            <tr><td class="diff-unchanged" >* Resuming a route <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">||
Parameter Name || Type || Default Value || Description || <br>| routeResumeTime | String
| | the initial scheduled Date and time as a Cron Expression for route resumption | <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">||
routeResumeTime || String || || the initial scheduled Date and time as a Cron Expression for
route resumption || <br> <br> <br></td></tr>
            <tr><td class="diff-unchanged" >Once the {{org.apache.camel.routepolicy.quartz.CronScheduledRoutePolicy}}
is created it can be wired into the camel route as follows <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="CronScheduledRoutePolicy-CronScheduledRoutePolicy"></a>CronScheduledRoutePolicy</h2>

<p>CronScheduledRoutePolicy is a <a href="/confluence/display/CAMEL/ScheduledRoutePolicy"
title="ScheduledRoutePolicy">ScheduledRoutePolicy</a> that facilitates route activation,
de-activation, suspension and resumption of routes based on a <a href="/confluence/display/CAMEL/Quartz"
title="Quartz">Quartz</a> <tt>CronTrigger</tt>.</p>

<p>Maven users will need to add a camel-quartz dependency to their <tt>pom.xml</tt>
to avail this capability.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;dependency&gt;</span>
    <span class="code-tag">&lt;groupId&gt;</span>org.apache.camel<span
class="code-tag">&lt;/groupId&gt;</span>
    <span class="code-tag">&lt;artifactId&gt;</span>camel-quartz<span
class="code-tag">&lt;/artifactId&gt;</span>
    <span class="code-tag">&lt;version&gt;</span>x.x.x<span class="code-tag">&lt;/version&gt;</span>
    <span class="code-tag"><span class="code-comment">&lt;!-- use the same
version as your Camel core version --&gt;</span></span>
<span class="code-tag">&lt;/dependency&gt;</span>
</pre>
</div></div>

<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/check.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td><b>Relationship to the Quartz
component</b><br />All Scheduled route policies share the scheduler created by
the Quartz component. In this way, scheduler, jobs and triggers can be managed in a common
and consistent way.</td></tr></table></div>

<h3><a name="CronScheduledRoutePolicy-Howitworks"></a>How it works</h3>

<p>In order to use a <a href="/confluence/display/CAMEL/CronScheduledRoutePolicy"
title="CronScheduledRoutePolicy">CronScheduledRoutePolicy</a> it is necessary to
instantiate an object of the type <tt>org.apache.camel.routepolicy.quartz.CronScheduledRoutePolicy</tt>.</p>

<p>In order to perform a route operation at a given time the following information must
be provided.</p>

<ul>
	<li>Starting a route
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Parameter Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> routeStartTime </td>
<td class='confluenceTd'> String </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> the initial scheduled Date and time as a Cron Expression for
route start </td>
</tr>
</tbody></table>
</div>
</li>
</ul>


<ul>
	<li>Stopping a route
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Parameter Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> routeStopTime </td>
<td class='confluenceTd'> String </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> the initial scheduled Date and time as a Cron Expression for
route stop </td>
</tr>
<tr>
<td class='confluenceTd'> routeStopGracePeriod </td>
<td class='confluenceTd'> int </td>
<td class='confluenceTd'> 10 seconds </td>
<td class='confluenceTd'> the time period to wait before initiating graceful route stop
</td>
</tr>
<tr>
<td class='confluenceTd'> routeStopTimeUnit </td>
<td class='confluenceTd'> long </td>
<td class='confluenceTd'> TimeUnit.MILLISECONDS </td>
<td class='confluenceTd'> the time unit for the grace period expressed as java.util.concurrent.TimeUnit
</td>
</tr>
</tbody></table>
</div>
</li>
</ul>


<ul>
	<li>Suspending a route
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Parameter Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> routeSuspendTime </td>
<td class='confluenceTd'> String </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> the initial scheduled Date and time as a Cron Expression for
route suspension </td>
</tr>
</tbody></table>
</div>
</li>
</ul>


<ul>
	<li>Resuming a route
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Parameter Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> routeResumeTime </td>
<td class='confluenceTd'> String </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> the initial scheduled Date and time as a Cron Expression for
route resumption </td>
</tr>
</tbody></table>
</div>
</li>
</ul>


<p>Once the <tt>org.apache.camel.routepolicy.quartz.CronScheduledRoutePolicy</tt>
is created it can be wired into the camel route as follows</p>

<h3><a name="CronScheduledRoutePolicy-Configuringthepolicy"></a>Configuring
the policy</h3>

<ul>
	<li>In Java</li>
</ul>


<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java"> 
CronScheduledRoutePolicy policy = <span class="code-keyword">new</span> CronScheduledRoutePolicy();
policy.setRouteStartTime(<span class="code-quote">"*/3 * * * * ?"</span>);
                
from(<span class="code-quote">"direct:start"</span>)
    .routeId(<span class="code-quote">"test"</span>)
    .routePolicy(policy)
    .to(<span class="code-quote">"mock:success"</span>);;
</pre>
</div></div>

<ul>
	<li>Using Spring</li>
</ul>


<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
&lt;bean id=<span class="code-quote">"date"</span> class=<span class="code-quote">"org.apache.camel.routepolicy.quartz.SimpleDate"</span>/&gt;

&lt;bean id=<span class="code-quote">"startPolicy"</span> class=<span class="code-quote">"org.apache.camel.routepolicy.quartz.CronScheduledRoutePolicy"</span>&gt;
    &lt;property name=<span class="code-quote">"routeStartTime"</span> value=<span
class="code-quote">"*/3 * * * * ?"</span>/&gt;
&lt;/bean&gt;
    
&lt;camelContext xmlns=<span class="code-quote">"http:<span class="code-comment">//camel.apache.org/schema/spring"</span>&gt;
</span>    &lt;route id=<span class="code-quote">"testRoute"</span>
routePolicyRef=<span class="code-quote">"startPolicy"</span>&gt;
        &lt;from uri=<span class="code-quote">"direct:start"</span>/&gt;
        &lt;to uri=<span class="code-quote">"mock:success"</span>/&gt;
    &lt;/route&gt;
&lt;/camelContext&gt;
</pre>
</div></div>

<h3><a name="CronScheduledRoutePolicy-SeeAlso"></a>See Also</h3>
<p><a href="/confluence/display/CAMEL/ScheduledRoutePolicy" title="ScheduledRoutePolicy">ScheduledRoutePolicy</a>
- for information on policy based scheduling capability for camel routes<br/>
<a href="/confluence/display/CAMEL/RoutePolicy" title="RoutePolicy">RoutePolicy</a>
- for information on route policies in general<br/>
<a href="/confluence/display/CAMEL/Quartz" title="Quartz">Quartz</a> -for more
information on the quartz component</p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/CronScheduledRoutePolicy">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=23339419&revisedVersion=2&originalVersion=1">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/CronScheduledRoutePolicy?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message