camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard Kettelerij (Confluence)" <conflue...@apache.org>
Subject [CONF] Apache Camel > CronScheduledRoutePolicy
Date Fri, 11 Oct 2013 13:11:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/en/2176/1/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/~rkettelerij">Richard
Kettelerij</a>
    </h4>
        <div id="versionComment">
        <b>Comment:</b>
        changed version number due to https://issues.apache.org/jira/browse/CAMEL-6789<br
/>
    </div>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > <br>{tip:title=Relationship
to the [Quartz2] component} <br></td></tr>
            <tr><td class="diff-changed-lines" >From Camel <span class="diff-changed-words">2.12.<span
class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">0</span><span
class="diff-added-chars"style="background-color: #dfd;">2</span></span> onwards
you can also make use of the [Quartz2] based implementation of this route policy. <br></td></tr>
            <tr><td class="diff-unchanged" >{tip} <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="theme: Default; brush: xml; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
&lt;dependency&gt;
    &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
    &lt;artifactId&gt;camel-quartz&lt;/artifactId&gt;
    &lt;version&gt;x.x.x&lt;/version&gt;
    &lt;!-- use the same version as your Camel core version --&gt;
&lt;/dependency&gt;
</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 <a
href="/confluence/display/CAMEL/Quartz" title="Quartz">Quartz</a> 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>

<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 <a
href="/confluence/display/CAMEL/Quartz2" title="Quartz2">Quartz2</a> component</b><br
/>From Camel 2.12.2 onwards you can also make use of the <a href="/confluence/display/CAMEL/Quartz2"
title="Quartz2">Quartz2</a> based implementation of this route policy.</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="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;"> 
CronScheduledRoutePolicy startPolicy = new CronScheduledRoutePolicy();
startPolicy.setRouteStartTime("*/3 * * * * ?");
                
from("direct:start")
    .routeId("testRoute").routePolicy(startPolicy).noAutoStartup()
    .to("mock:success");;
</pre>
</div></div>

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


<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: xml; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
&lt;bean id="startPolicy" class="org.apache.camel.routepolicy.quartz.CronScheduledRoutePolicy"&gt;
    &lt;property name="routeStartTime" value="*/3 * * * * ?"/&gt;
&lt;/bean&gt;
    
&lt;camelContext xmlns="http://camel.apache.org/schema/spring"&gt;
    &lt;route id="testRoute" routePolicyRef="startPolicy" autoStartup="false"&gt;
        &lt;from uri="direct:start"/&gt;
        &lt;to uri="mock:success"/&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;" class="grey">
                        <a href="https://cwiki.apache.org/confluence/users/removespacenotification.action?spaceKey=CAMEL">Stop
watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://cwiki.apache.org/confluence/users/editmyemailsettings.action">Change
email 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=8&originalVersion=7">View
Changes</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message