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 Mon, 08 Aug 2011 16:39: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/~akarpe">Ashwin
Karpe</a>
    </h4>
        <br/>
                         <h4>Changes (1)</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-added-lines" style="background-color: #dfd;">*Available
as of Camel version 2.6* <br> <br></td></tr>
            <tr><td class="diff-unchanged" >CronScheduledRoutePolicy is a [ScheduledRoutePolicy]
that facilitates route activation, de-activation, suspension and resumption of routes based
on a [Quartz] {{CronTrigger}}. <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><b>Available as of Camel version 2.6</b></p>

<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=3&originalVersion=2">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