camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Babak Vahdat (Confluence)" <conflue...@apache.org>
Subject [CONF] Apache Camel > SimpleScheduledRoutePolicy
Date Sat, 21 Sep 2013 10:42: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/SimpleScheduledRoutePolicy">SimpleScheduledRoutePolicy</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~bvahdat">Babak
Vahdat</a>
    </h4>
        <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" >{code} <br> <br></td></tr>
            <tr><td class="diff-unchanged" >{tip:title=Relationship to the [Quartz]
component} <br></td></tr>
            <tr><td class="diff-unchanged" >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. <br>{tip} <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{tip:title=Relationship
to the [Quartz2] component} <br>From Camel 2.12.0 onwards you can also make use of the
[Quartz2] implementation of this route policy. <br>{tip} <br> <br></td></tr>
            <tr><td class="diff-unchanged" >h3. How it works <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="SimpleScheduledRoutePolicy-SimpleScheduledRoutePolicy"></a>SimpleScheduledRoutePolicy</h2>
<p><b>Available as of Camel 2.6</b></p>

<p>SimpleScheduledRoutePolicy 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> SimpleTrigger.</p>

<p>Maven users will need to add a <tt>camel-quartz</tt> 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.0 onwards you can also make use of the <a href="/confluence/display/CAMEL/Quartz2"
title="Quartz2">Quartz2</a> implementation of this route policy.</td></tr></table></div>

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

<p>In order to use a SimpleScheduledRoutePolicy it is necessary to instantiate an object
of the type <tt>org.apache.camel.routepolicy.quartz.SimpleScheduledRoutePolicy</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</li>
</ul>


<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Parameter Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Default </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> routeStartDate </td>
<td class='confluenceTd'> java.util.Date </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> the initial scheduled Date and time for route start </td>
</tr>
<tr>
<td class='confluenceTd'> routeStartRepeatCount </td>
<td class='confluenceTd'> int </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> no of times to repeat the job </td>
</tr>
<tr>
<td class='confluenceTd'> routeStartRepeatInterval </td>
<td class='confluenceTd'> long </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> the time interval in milliseconds to trigger the next attempt
to start the route </td>
</tr>
</tbody></table>
</div>


<ul>
	<li>Stopping a route</li>
</ul>


<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Parameter Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Default </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> routeStopDate </td>
<td class='confluenceTd'> java.util.Date </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> the initial scheduled Date and time for route stop </td>
</tr>
<tr>
<td class='confluenceTd'> routeStopRepeatCount </td>
<td class='confluenceTd'> int </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> no of times to repeat the job </td>
</tr>
<tr>
<td class='confluenceTd'> routeStopRepeatInterval </td>
<td class='confluenceTd'> long </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> the time interval in milliseconds to trigger the next attempt
to stop the route </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>


<ul>
	<li>Suspending a route</li>
</ul>


<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Parameter Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Default </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> routeSuspendDate </td>
<td class='confluenceTd'> java.util.Date </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> the initial scheduled Date and time for route suspension </td>
</tr>
<tr>
<td class='confluenceTd'> routeSuspendRepeatCount </td>
<td class='confluenceTd'> int </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> no of times to repeat the job </td>
</tr>
<tr>
<td class='confluenceTd'> routeSuspendRepeatInterval </td>
<td class='confluenceTd'> long </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> the time interval in milliseconds to trigger the next attempt
to suspend the route </td>
</tr>
</tbody></table>
</div>


<ul>
	<li>Resuming a route</li>
</ul>


<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Parameter Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Default </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> routeResumeDate </td>
<td class='confluenceTd'> java.util.Date </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> the initial scheduled Date and time for route start </td>
</tr>
<tr>
<td class='confluenceTd'> routeResumeRepeatCount </td>
<td class='confluenceTd'> int </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> no of times to repeat the job </td>
</tr>
<tr>
<td class='confluenceTd'> routeResumeRepeatInterval </td>
<td class='confluenceTd'> long </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> the time interval in milliseconds to trigger the next attempt
to resume the route </td>
</tr>
</tbody></table>
</div>


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

<h3><a name="SimpleScheduledRoutePolicy-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;"> 
SimpleScheduledRoutePolicy policy = new SimpleScheduledRoutePolicy();
long startTime = System.currentTimeMillis() + 3000L;
policy.setRouteStartDate(new Date(startTime));
policy.setRouteStartRepeatCount(1);
policy.setRouteStartRepeatInterval(3000);
                
from("direct:start")
   .routeId("test")
   .routePolicy(policy)
   .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: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
&lt;bean id="date" class="org.apache.camel.routepolicy.quartz.SimpleDate"/&gt;

&lt;bean id="startPolicy" class="org.apache.camel.routepolicy.quartz.SimpleScheduledRoutePolicy"&gt;
    &lt;property name="routeStartDate" ref="date"/&gt;
    &lt;property name="routeStartRepeatCount" value="1"/&gt;
    &lt;property name="routeStartRepeatInterval" value="3000"/&gt;    	
&lt;/bean&gt; 
 	
&lt;camelContext xmlns="http://camel.apache.org/schema/spring"&gt;
    &lt;route id="myroute" routePolicyRef="startPolicy"&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="SimpleScheduledRoutePolicy-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/SimpleScheduledRoutePolicy">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=23339415&revisedVersion=4&originalVersion=3">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/SimpleScheduledRoutePolicy?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message