Modified: websites/production/camel/content/graceful-shutdown.html
==============================================================================
--- websites/production/camel/content/graceful-shutdown.html (original)
+++ websites/production/camel/content/graceful-shutdown.html Fri Aug 25 
08:22:01 2017
@@ -36,17 +36,6 @@
     <![endif]-->
 
 
-  <link href='//camel.apache.org/styles/highlighter/styles/shCoreCamel.css' 
rel='stylesheet' type='text/css' />
-  <link href='//camel.apache.org/styles/highlighter/styles/shThemeCamel.css' 
rel='stylesheet' type='text/css' />
-  <script src='//camel.apache.org/styles/highlighter/scripts/shCore.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushJava.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushXml.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushPlain.js' 
type='text/javascript'></script>
-  
-  <script type="text/javascript">
-  SyntaxHighlighter.defaults['toolbar'] = false;
-  SyntaxHighlighter.all();
-  </script>
 
     <title>
     Apache Camel: Graceful Shutdown
@@ -86,8 +75,7 @@
        <tbody>
         <tr>
         <td valign="top" width="100%">
-<div class="wiki-content maincontent"><h2 
id="GracefulShutdown-GracefulShutdown">Graceful 
Shutdown</h2><p><strong>Available as of Camel 2.2</strong></p><p>Camel now 
supports a pluggable shutdown strategy using 
<code>org.apache.camel.spi.ShutdownStrategy</code>. Its responsible for 
shutting down routes in a graceful manner. The other resources will still be 
handled by <a shape="rect" href="camelcontext.html">CamelContext</a> to 
shutdown. This leaves the problem at hand with properly shutting down all the 
routes in a reliable manner to the <code>ShutdownStrategy</code>.</p><p>Camel 
provides a default strategy in the 
<code>org.apache.camel.impl.DefaultShutdownStrategy</code> which is capable of 
doing that.</p><h3 
id="GracefulShutdown-DefaultShutdownStrategy">DefaultShutdownStrategy</h3><p>The
 default strategy will gracefully shutdown routes:</p><ul 
class="alternate"><li><strong>Camel 2.2:</strong> in the same order they was 
started</li><li><strong>Camel 2.3:</strong> in the reverse ord
 er they was started. The option <code>shutdownRoutesInReverseOrder</code> can 
be used to use the old behavior.</li><li>let pending and current in flight 
exchanges run to completion before shutting down</li><li>using a timeout of 300 
seconds which then forces a shutdown now</li></ul><p>You can configure the 
timeout, and whether it should shutdown now remaining routes when the timeout 
occurred or ignore. See the setters on the class.</p><p>It will output to log 
the progress during graceful shutdown as shown in an example below</p><div 
class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[2009-12-20 10:56:53,055 [main           ] 
INFO  DefaultCamelContext            - Apache Camel  (CamelContext:camel-1) is 
stopping
+<div class="wiki-content maincontent"><h2 
id="GracefulShutdown-GracefulShutdown">Graceful 
Shutdown</h2><p><strong>Available as of Camel 2.2</strong></p><p>Camel now 
supports a pluggable shutdown strategy using 
<code>org.apache.camel.spi.ShutdownStrategy</code>. Its responsible for 
shutting down routes in a graceful manner. The other resources will still be 
handled by <a shape="rect" href="camelcontext.html">CamelContext</a> to 
shutdown. This leaves the problem at hand with properly shutting down all the 
routes in a reliable manner to the <code>ShutdownStrategy</code>.</p><p>Camel 
provides a default strategy in the 
<code>org.apache.camel.impl.DefaultShutdownStrategy</code> which is capable of 
doing that.</p><h3 
id="GracefulShutdown-DefaultShutdownStrategy">DefaultShutdownStrategy</h3><p>The
 default strategy will gracefully shutdown routes:</p><ul 
class="alternate"><li><strong>Camel 2.2:</strong> in the same order they was 
started</li><li><strong>Camel 2.3:</strong> in the reverse ord
 er they was started. The option <code>shutdownRoutesInReverseOrder</code> can 
be used to use the old behavior.</li><li>let pending and current in flight 
exchanges run to completion before shutting down</li><li>using a timeout of 300 
seconds which then forces a shutdown now</li></ul><p>You can configure the 
timeout, and whether it should shutdown now remaining routes when the timeout 
occurred or ignore. See the setters on the class.</p><p>It will output to log 
the progress during graceful shutdown as shown in an example 
below</p><plain-text-body>2009-12-20 10:56:53,055 [main           ] INFO  
DefaultCamelContext            - Apache Camel  (CamelContext:camel-1) is 
stopping
 2009-12-20 10:56:53,056 [main           ] INFO  DefaultShutdownStrategy        
- Starting to graceful shutdown routes (timeout 300 seconds)
 2009-12-20 10:56:53,059 [1: ShutdownTask] INFO  DefaultShutdownStrategy        
- Waiting as there are still 5 inflight exchanges to complete before we can 
shutdown
 2009-12-20 10:56:54,060 [1: ShutdownTask] INFO  DefaultShutdownStrategy        
- Waiting as there are still 4 inflight exchanges to complete before we can 
shutdown
@@ -97,59 +85,10 @@
 2009-12-20 10:56:58,069 [main           ] INFO  DefaultShutdownStrategy        
- Graceful shutdown of routes complete in 5 seconds.
 2009-12-20 10:56:58,072 [main           ] INFO  DefaultInflightRepository      
- Shutting down with no inflight exchanges.
 2009-12-20 10:56:58,077 [main           ] INFO  DefaultCamelContext            
- Apache Camel  (CamelContext:camel-1) stopped
-]]></script>
-</div></div><p>Notice how it waits while there are inflight exchanges still 
being processed before it can shutdown.</p><h4 
id="GracefulShutdown-Suppressingloggingduetotimeoutnotallowingallinflightmessagestocomplete">Suppressing
 logging due to timeout not allowing all inflight messages to 
complete</h4><p><strong>Available as of Camel 2.12</strong></p><p>If a graceful 
shutdown could not shutdown cleanly within the given timeout period, then Camel 
performs a more aggressive shutdown by forcing routes and thread pools etc to 
shutdown. And as well the routing engine will reject continue processing <a 
shape="rect" href="exchange.html">Exchange</a>s. If this happens you may see 
WARN logs about <a shape="rect" href="exchange.html">Exchange</a>s being 
rejected and other failures due the forced shutdown.</p><p>If you do not want 
to see these logs, you can suppress this by setting the option 
SuppressLoggingOnTimeout to true.</p><div class="code panel pdl" 
style="border-width: 1px;"><div class=
 "codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[context.getShutdownStrategy().setSuppressLoggingOnTimeout(true);
-]]></script>
-</div></div><p>Notice the suppress is a "best effort" though there may still 
be some logs coming from 3rd party libraries and whatnot, which Camel cannot 
control.</p><h4 
id="GracefulShutdown-Logginginflightexchangeinformationontimeout">Logging 
inflight exchange information on timeout</h4><p><strong>Available as of Camel 
2.15</strong></p><p>If a graceful shutdown could not shutdown cleanly within 
the given timeout period, then Camel performs a more aggressive shutdown by 
forcing routes and thread pools etc to shutdown. When the timeout happens, then 
Camel logs information about the current inflight exchanges, which shows from 
which route the exchange origins, and where it currently is being routed. For 
example the logging below, shows that there is 1 inflight exchange, that 
origins from route1, and currently is still in route1 at the "delay1" node. The 
elapsed is time in millis how long at the current node (eg delay1) and duration 
is total time in mills.</p><p>If you enable DEBUG log
 ging level on&#160;<code>org.apache.camel.impl.DefaultShutdownStrategy</code> 
then it logs the same inflight exchange information during graceful 
shutdown</p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[2015-01-12 13:23:23,656 [ - ShutdownTask] 
INFO DefaultShutdownStrategy        - There are 1 inflight exchanges:
-       InflightExchange: [exchangeId=ID-davsclaus-air-62213-1421065401253-0-3, 
fromRouteId=route1, routeId=route1, nodeId=delay1, elapsed=2007, 
duration=2017]]]></script>
-</div></div><p><span style="line-height: 1.4285715;">If you do not want to see 
these logs, you can turn this off by setting the option </span><span 
style="line-height: 1.4285715;">logInflightExchangesOnTimeout</span><span 
style="line-height: 1.4285715;">&#160;to false.</span></p><div class="code 
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[context.getShutdownStrategy().setLogInflightExchangesOnTimeout(false);
-]]></script>
-</div></div><h3 id="GracefulShutdown-Controllingorderingofroutes">Controlling 
ordering of routes</h3><p>You can configure the order in which routes should be 
started, and thus also the same order they are being shutdown.<br clear="none"> 
See more at <a shape="rect" 
href="configuring-route-startup-ordering-and-autostartup.html">Configuring 
route startup ordering and autostartup</a>.</p><h3 
id="GracefulShutdown-Finegrainedconfiguration">Fine grained 
configuration</h3><p>You can control two areas that influence graceful shutdown 
in the Camel routing:</p><ul 
class="alternate"><li><code>ShutdownRoute</code></li><li><code>ShutdownRunningTask</code></li></ul><p>These
 options can be configured on two scopes: <code>context</code> and 
<code>route</code>. Where a route will fallback to the <code>context</code> 
scoped option, if not explicit configured. (same principle as <a shape="rect" 
href="error-handler.html">Error Handler</a>, etc.).</p><h4 
id="GracefulShutdown-ShutdownRoute">ShutdownRoute
 </h4><p>This option can control how a given route should act during graceful 
shutdown. It has two values <code>Default</code> and <code>Defer</code>. The 
<code>Default</code> is obviously the default option which lets Camel shutdown 
the route as early as possible. The <code>Defer</code> is used to defer 
shutting down this route to a later stage. This is useful when other routes are 
dependent upon it. For example an internal route which other routes 
reuse.</p><p>For example in the route below we have two routes, where route 1 
is dependent upon route 2. At shutdown we want route 1 to complete all its 
current messages and we also want the 2nd route to do this as well. So we can 
mark both routes to <code>Defer</code> but since route 1 is a <a shape="rect" 
href="seda.html">SEDA</a> based route its <code>Defer</code> by default (it 
uses <code>ShutdownAware</code>).</p><p>A Java DSL based example to defer 
shutting down the 2nd route:</p><div class="code panel pdl" 
style="border-width: 1px;
 "><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-public void configure() throws Exception {
-    from(&quot;seda:foo&quot;)
-        .startupOrder(1)
-        .to(&quot;file://target/deferred&quot;);
-
-    // use file component to transfer files from route 1 -&gt; route 2 as it
-    // will normally suspend, but by deferring this we can let route 1
-    // complete while shutting down
-    MyDeferFileEndpoint defer = new 
MyDeferFileEndpoint(&quot;file://target/deferred?initialDelay=0&amp;delay=10&quot;,
 getContext().getComponent(&quot;file&quot;));
-    defer.setFile(new File(&quot;target/deferred&quot;));
-
-    from(defer)
-        // defer shutting down this route as the 1st route depends upon it
-        .startupOrder(2).shutdownRoute(Defer)
-        .to(&quot;mock:bar&quot;);
-}
-]]></script>
-</div></div>The same route in Spring XML would be:<div class="error"><span 
class="error">Error formatting macro: snippet: 
java.lang.IndexOutOfBoundsException: Index: 20, Size: 20</span> </div><div 
class="confluence-information-macro confluence-information-macro-tip"><p 
class="title">Defer shutting down internal routes only</p><span class="aui-icon 
aui-icon-small aui-iconfont-approve 
confluence-information-macro-icon"></span><div 
class="confluence-information-macro-body"><p>Its best to only defer shutting 
down internal routes only. As <strong>public</strong> routes should shutdown as 
quickly as possible otherwise it will just keep intake new messages which will 
delay the shutdown processor. Or even have it timeout if a lot of new messages 
keep coming in.</p></div></div><h4 
id="GracefulShutdown-ShutdownRunningTask">ShutdownRunningTask</h4><p>This 
option control how a given route consumer acts during shutdown. Most route 
consumer will only operate on a single task (message), however th
 e <a shape="rect" href="batch-consumer.html">Batch Consumer</a> can operate on 
many messages (in a batch). This option is for those kind of consumers. By 
default it uses the option <code>CompleteCurrentTaskOnly</code> which mean that 
the current <em>in progress</em> task (message) will be completed and then the 
consumer will shutdown. The other option <code>CompleteAllTasks</code> allows 
the consumer to complete all the tasks (messages) before shutting down. For 
example a <a shape="rect" href="file2.html">File</a> consumer will process all 
the pending files it has picked up before shutting down.</p><p>A Java DSL based 
example to complete all messages during shutting down the first route:</p><div 
class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-public void configure() throws Exception {
-    from(url).routeId(&quot;foo&quot;).noAutoStartup()
-        // let it complete all tasks during shutdown
-        .shutdownRunningTask(ShutdownRunningTask.CompleteAllTasks)
-        .process(new MyProcessor())
-        .to(&quot;mock:bar&quot;);
-}
-]]></script>
-</div></div>The same route in Spring XML would be:<div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-&lt;camelContext xmlns=&quot;http://camel.apache.org/schema/spring&quot;&gt;
-    &lt;!-- let this route complete all its pending messages when asked to 
shutdown --&gt;
-    &lt;route id=&quot;foo&quot; autoStartup=&quot;false&quot; 
shutdownRunningTask=&quot;CompleteAllTasks&quot;&gt;
-        &lt;from 
uri=&quot;file:target/pending?initialDelay=0&amp;amp;delay=10&quot;/&gt;
-        &lt;delay&gt;&lt;constant&gt;1000&lt;/constant&gt;&lt;/delay&gt;
-        &lt;process ref=&quot;myProcessor&quot;/&gt;
-        &lt;to uri=&quot;mock:bar&quot;/&gt;
-    &lt;/route&gt;
-
-&lt;/camelContext&gt;
-]]></script>
-</div></div><h3 id="GracefulShutdown-JMXmanaged">JMX managed</h3><p>The 
<code>ShutdownStrategy</code> is JMX aware as well so you can manage it from a 
JMX console. For example you can change the timeout value.</p><h3 
id="GracefulShutdown-Shuttingdownindividualroutes">Shutting down individual 
routes</h3><p><strong>Available as of Camel 2.3</strong><br clear="none"> Its 
now possible to gracefully shutdown an individual route using 
<code>shutdownRoute(routeId)</code> method on <code>CamelContext</code>. Its 
also possible to provide a specific timeout to use instead of the default 
timeout settings using <code>shutdownRoute(routeId, timeout, 
timeUnit)</code>.</p><h3 id="GracefulShutdown-Developerrelated">Developer 
related</h3><p>If you develop your own Camel component or want to implement 
your own shutdown strategy then read this section for details.</p><h4 
id="GracefulShutdown-ShutdownStrategy">ShutdownStrategy</h4><p>You can 
implement your own strategy to control the shutdown by implem
 enting the <code>org.apache.camel.spi.ShutdownStrategy</code> and the set it 
on the <code>CamelContext</code> using the <code>setShutdownStrategy</code> 
method.</p><p>When using Spring XML you then just define a spring bean which 
implements the <code>org.apache.camel.spi.ShutdownStrategy</code> and Camel 
will look it up at startup and use it instead of its default. See more at <a 
shape="rect" 
href="advanced-configuration-of-camelcontext-using-spring.html">Advanced 
configuration of CamelContext using Spring</a>.</p><h4 
id="GracefulShutdown-ShutdownAware">ShutdownAware</h4><p>The interface 
<code>org.apache.camel.spi.ShutdownAware</code> is an optional interface 
consumers can implement to have fine grained control during shutdown. The 
<code>ShutdownStrategy</code> must be able to deal with consumers which 
implement this interface. This interface was introduced to cater for in memory 
consumers such as <a shape="rect" href="seda.html">SEDA</a> which potentially 
have a number of pending m
 essages on its internal in memory queues. What this allows is to let it 
control the shutdown process to let it complete its pending messages.</p><p>The 
method <code>getPendingExchangesSize</code> should return the number of pending 
messages which reside on the in memory queues.<br clear="none"> The method 
<code>deferShutdown</code> should return <code>true</code> to defer the 
shutdown to a later stage, when there are no more pending and inflight 
messages.</p><p><a shape="rect" href="batch-consumer.html">Batch Consumer</a> 
should implement <code>ShutdownAware</code> so they properly support the 
<code>ShutdownRunningTask</code> option. See <code>GenericFileConsumer</code> 
for an example.</p><h3 id="GracefulShutdown-SeeAlso">See Also</h3><ul 
class="alternate"><li><a shape="rect" 
href="configuring-route-startup-ordering-and-autostartup.html">Configuring 
route startup ordering and autostartup</a></li><li><a shape="rect" 
href="advanced-configuration-of-camelcontext-using-spring.html">Adva
 nced configuration of CamelContext using Spring</a></li><li><a shape="rect" 
href="user-guide.html">User Guide</a></li></ul></div>
+</plain-text-body><p>Notice how it waits while there are inflight exchanges 
still being processed before it can shutdown.</p><h4 
id="GracefulShutdown-Suppressingloggingduetotimeoutnotallowingallinflightmessagestocomplete">Suppressing
 logging due to timeout not allowing all inflight messages to 
complete</h4><p><strong>Available as of Camel 2.12</strong></p><p>If a graceful 
shutdown could not shutdown cleanly within the given timeout period, then Camel 
performs a more aggressive shutdown by forcing routes and thread pools etc to 
shutdown. And as well the routing engine will reject continue processing <a 
shape="rect" href="exchange.html">Exchange</a>s. If this happens you may see 
WARN logs about <a shape="rect" href="exchange.html">Exchange</a>s being 
rejected and other failures due the forced shutdown.</p><p>If you do not want 
to see these logs, you can suppress this by setting the option 
SuppressLoggingOnTimeout to 
true.</p><plain-text-body>context.getShutdownStrategy().setSuppressLo
 ggingOnTimeout(true);
+</plain-text-body><p>Notice the suppress is a "best effort" though there may 
still be some logs coming from 3rd party libraries and whatnot, which Camel 
cannot control.</p><h4 
id="GracefulShutdown-Logginginflightexchangeinformationontimeout">Logging 
inflight exchange information on timeout</h4><p><strong>Available as of Camel 
2.15</strong></p><p>If a graceful shutdown could not shutdown cleanly within 
the given timeout period, then Camel performs a more aggressive shutdown by 
forcing routes and thread pools etc to shutdown. When the timeout happens, then 
Camel logs information about the current inflight exchanges, which shows from 
which route the exchange origins, and where it currently is being routed. For 
example the logging below, shows that there is 1 inflight exchange, that 
origins from route1, and currently is still in route1 at the "delay1" node. The 
elapsed is time in millis how long at the current node (eg delay1) and duration 
is total time in mills.</p><p>If you enable DEB
 UG logging level 
on&#160;<code>org.apache.camel.impl.DefaultShutdownStrategy</code> then it logs 
the same inflight exchange information during graceful 
shutdown</p><plain-text-body>2015-01-12 13:23:23,656 [ - ShutdownTask] INFO 
DefaultShutdownStrategy        - There are 1 inflight exchanges:
+       InflightExchange: [exchangeId=ID-davsclaus-air-62213-1421065401253-0-3, 
fromRouteId=route1, routeId=route1, nodeId=delay1, elapsed=2007, 
duration=2017]</plain-text-body><p><span style="line-height: 1.4285715;">If you 
do not want to see these logs, you can turn this off by setting the option 
</span><span style="line-height: 
1.4285715;">logInflightExchangesOnTimeout</span><span style="line-height: 
1.4285715;">&#160;to 
false.</span></p><plain-text-body>context.getShutdownStrategy().setLogInflightExchangesOnTimeout(false);
+</plain-text-body><h3 
id="GracefulShutdown-Controllingorderingofroutes">Controlling ordering of 
routes</h3><p>You can configure the order in which routes should be started, 
and thus also the same order they are being shutdown.<br clear="none"> See more 
at <a shape="rect" 
href="configuring-route-startup-ordering-and-autostartup.html">Configuring 
route startup ordering and autostartup</a>.</p><h3 
id="GracefulShutdown-Finegrainedconfiguration">Fine grained 
configuration</h3><p>You can control two areas that influence graceful shutdown 
in the Camel routing:</p><ul 
class="alternate"><li><code>ShutdownRoute</code></li><li><code>ShutdownRunningTask</code></li></ul><p>These
 options can be configured on two scopes: <code>context</code> and 
<code>route</code>. Where a route will fallback to the <code>context</code> 
scoped option, if not explicit configured. (same principle as <a shape="rect" 
href="error-handler.html">Error Handler</a>, etc.).</p><h4 
id="GracefulShutdown-ShutdownRoute">Shutdow
 nRoute</h4><p>This option can control how a given route should act during 
graceful shutdown. It has two values <code>Default</code> and 
<code>Defer</code>. The <code>Default</code> is obviously the default option 
which lets Camel shutdown the route as early as possible. The 
<code>Defer</code> is used to defer shutting down this route to a later stage. 
This is useful when other routes are dependent upon it. For example an internal 
route which other routes reuse.</p><p>For example in the route below we have 
two routes, where route 1 is dependent upon route 2. At shutdown we want route 
1 to complete all its current messages and we also want the 2nd route to do 
this as well. So we can mark both routes to <code>Defer</code> but since route 
1 is a <a shape="rect" href="seda.html">SEDA</a> based route its 
<code>Defer</code> by default (it uses <code>ShutdownAware</code>).</p><p>A 
Java DSL based example to defer shutting down the 2nd 
route:<plain-text-body>{snippet:id=e1|lang=java|url=camel
 
/trunk/camel-core/src/test/java/org/apache/camel/processor/ShutdownDeferTest.java}</plain-text-body>The
 same route in Spring XML would 
be:<plain-text-body>{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ShutdownDeferTest.xml}</plain-text-body></p><parameter
 ac:name="title">Defer shutting down internal routes 
only</parameter><rich-text-body><p>Its best to only defer shutting down 
internal routes only. As <strong>public</strong> routes should shutdown as 
quickly as possible otherwise it will just keep intake new messages which will 
delay the shutdown processor. Or even have it timeout if a lot of new messages 
keep coming in.</p></rich-text-body><h4 
id="GracefulShutdown-ShutdownRunningTask">ShutdownRunningTask</h4><p>This 
option control how a given route consumer acts during shutdown. Most route 
consumer will only operate on a single task (message), however the <a 
shape="rect" href="batch-consumer.html">Batch Consumer
 </a> can operate on many messages (in a batch). This option is for those kind 
of consumers. By default it uses the option 
<code>CompleteCurrentTaskOnly</code> which mean that the current <em>in 
progress</em> task (message) will be completed and then the consumer will 
shutdown. The other option <code>CompleteAllTasks</code> allows the consumer to 
complete all the tasks (messages) before shutting down. For example a <a 
shape="rect" href="file2.html">File</a> consumer will process all the pending 
files it has picked up before shutting down.</p><p>A Java DSL based example to 
complete all messages during shutting down the first 
route:<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ShutdownCompleteAllTasksTest.java}</plain-text-body>The
 same route in Spring XML would 
be:<plain-text-body>{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ShutdownCompleteAllTasksTe
 st.xml}</plain-text-body></p><h3 id="GracefulShutdown-JMXmanaged">JMX 
managed</h3><p>The <code>ShutdownStrategy</code> is JMX aware as well so you 
can manage it from a JMX console. For example you can change the timeout 
value.</p><h3 id="GracefulShutdown-Shuttingdownindividualroutes">Shutting down 
individual routes</h3><p><strong>Available as of Camel 2.3</strong><br 
clear="none"> Its now possible to gracefully shutdown an individual route using 
<code>shutdownRoute(routeId)</code> method on <code>CamelContext</code>. Its 
also possible to provide a specific timeout to use instead of the default 
timeout settings using <code>shutdownRoute(routeId, timeout, 
timeUnit)</code>.</p><h3 id="GracefulShutdown-Developerrelated">Developer 
related</h3><p>If you develop your own Camel component or want to implement 
your own shutdown strategy then read this section for details.</p><h4 
id="GracefulShutdown-ShutdownStrategy">ShutdownStrategy</h4><p>You can 
implement your own strategy to control the s
 hutdown by implementing the <code>org.apache.camel.spi.ShutdownStrategy</code> 
and the set it on the <code>CamelContext</code> using the 
<code>setShutdownStrategy</code> method.</p><p>When using Spring XML you then 
just define a spring bean which implements the 
<code>org.apache.camel.spi.ShutdownStrategy</code> and Camel will look it up at 
startup and use it instead of its default. See more at <a shape="rect" 
href="advanced-configuration-of-camelcontext-using-spring.html">Advanced 
configuration of CamelContext using Spring</a>.</p><h4 
id="GracefulShutdown-ShutdownAware">ShutdownAware</h4><p>The interface 
<code>org.apache.camel.spi.ShutdownAware</code> is an optional interface 
consumers can implement to have fine grained control during shutdown. The 
<code>ShutdownStrategy</code> must be able to deal with consumers which 
implement this interface. This interface was introduced to cater for in memory 
consumers such as <a shape="rect" href="seda.html">SEDA</a> which potentially 
have a nu
 mber of pending messages on its internal in memory queues. What this allows is 
to let it control the shutdown process to let it complete its pending 
messages.</p><p>The method <code>getPendingExchangesSize</code> should return 
the number of pending messages which reside on the in memory queues.<br 
clear="none"> The method <code>deferShutdown</code> should return 
<code>true</code> to defer the shutdown to a later stage, when there are no 
more pending and inflight messages.</p><p><a shape="rect" 
href="batch-consumer.html">Batch Consumer</a> should implement 
<code>ShutdownAware</code> so they properly support the 
<code>ShutdownRunningTask</code> option. See <code>GenericFileConsumer</code> 
for an example.</p><h3 id="GracefulShutdown-SeeAlso">See Also</h3><ul 
class="alternate"><li><a shape="rect" 
href="configuring-route-startup-ordering-and-autostartup.html">Configuring 
route startup ordering and autostartup</a></li><li><a shape="rect" 
href="advanced-configuration-of-camelcontext-using-
 spring.html">Advanced configuration of CamelContext using 
Spring</a></li><li><a shape="rect" href="user-guide.html">User 
Guide</a></li></ul></div>
         </td>
         <td valign="top">
           <div class="navigation">

Modified: websites/production/camel/content/groovy.html
==============================================================================
--- websites/production/camel/content/groovy.html (original)
+++ websites/production/camel/content/groovy.html Fri Aug 25 08:22:01 2017
@@ -41,7 +41,6 @@
   <script src='//camel.apache.org/styles/highlighter/scripts/shCore.js' 
type='text/javascript'></script>
   <script src='//camel.apache.org/styles/highlighter/scripts/shBrushJava.js' 
type='text/javascript'></script>
   <script src='//camel.apache.org/styles/highlighter/scripts/shBrushXml.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushPlain.js' 
type='text/javascript'></script>
   
   <script type="text/javascript">
   SyntaxHighlighter.defaults['toolbar'] = false;
@@ -114,46 +113,19 @@ from(&quot;queue:foo&quot;).filter(groov
             &lt;/filter&gt;
         &lt;/route&gt;
 ]]></script>
-</div></div><p></p><h3 
id="Groovy-ScriptContextOptions"><code>ScriptContext</code> 
Options</h3><p>&#160;</p><div class="confluence-information-macro 
confluence-information-macro-information"><span class="aui-icon aui-icon-small 
aui-iconfont-info confluence-information-macro-icon"></span><div 
class="confluence-information-macro-body">The&#160;<code>JSR-223</code> 
scripting language's&#160;<strong><code>ScriptContext</code></strong> is 
pre-configured with the following attributes all set at 
<strong><code>ENGINE_SCOPE</code></strong>.</div></div><div 
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" 
rowspan="1" class="confluenceTh"><p>Attribute</p></th><th colspan="1" 
rowspan="1" class="confluenceTh"><p>Type</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Value</p></th></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><span><code>camelContext</code><br 
clear="none"></span></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><cod
 e>org.apache.camel.CamelContext</code></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>The Camel Context.</p></td></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>context</code></p></td><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p><code>org.apache.camel.CamelContext</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>The Camel Context (cannot be 
used in groovy).</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>exchange</code></p></td><td colspan="1" 
rowspan="1" 
class="confluenceTd"><p><code>org.apache.camel.Exchange</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>The current 
Exchange.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>properties</code></p></td><td colspan="1" 
rowspan="1" 
class="confluenceTd"><p><code>org.apache.camel.builder.script.PropertiesFunction</code></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.9:</strong> Fun
 ction with a <strong><code>resolve</code></strong> method to make it easier to 
use Camels <a shape="rect" href="properties.html">Properties</a> component from 
scripts. See further below for example.</p></td></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>request</code></p></td><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p><code>org.apache.camel.Message</code></p></td><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p>The&#160;<strong><code>IN</code></strong> 
message.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>response</code></p></td><td colspan="1" 
rowspan="1" 
class="confluenceTd"><p><code>org.apache.camel.Message</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Deprecated</strong>: 
The&#160;<strong><code>OUT</code></strong> message. 
The&#160;<strong><code>OUT</code></strong> message 
is&#160;<strong><code>null</code></strong> by default. Use the 
<strong><code>IN</code></strong> message instead.</p></
 td></tr></tbody></table></div><p>See <a shape="rect" 
href="scripting-languages.html">Scripting Languages</a> for the list of 
languages with explicit DSL support.</p><h3 
id="Groovy-PassingAdditionalArgumentstotheScriptingEngine">Passing Additional 
Arguments to the&#160;<code>ScriptingEngine</code></h3><p><strong>Available 
from Camel 2.8</strong></p><p>You can provide additional arguments to the 
<strong><code>ScriptingEngine</code></strong> using a header on the Camel 
message with the key 
<strong><code>CamelScriptArguments</code></strong>.</p><p>Example:</p><div 
class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-public void testArgumentsExample() throws Exception {
-    getMockEndpoint(&quot;mock:result&quot;).expectedMessageCount(0);
-    getMockEndpoint(&quot;mock:unmatched&quot;).expectedMessageCount(1);
-
-    // additional arguments to ScriptEngine
-    Map&lt;String, Object&gt; arguments = new HashMap&lt;String, Object&gt;();
-    arguments.put(&quot;foo&quot;, &quot;bar&quot;);
-    arguments.put(&quot;baz&quot;, 7);
-
-    // those additional arguments is provided as a header on the Camel Message
-    template.sendBodyAndHeader(&quot;direct:start&quot;, &quot;hello&quot;, 
ScriptBuilder.ARGUMENTS, arguments);
-
-    assertMockEndpointsSatisfied();
-}
-]]></script>
-</div></div><h3 id="Groovy-UsingPropertiesFunction">Using Properties 
Function</h3><p><strong>Available from Camel 2.9</strong></p><p>If you need to 
use the <a shape="rect" href="properties.html">Properties</a> component from a 
script to lookup property placeholders, then its a bit cumbersome to do so. For 
example, to set a header name&#160;<strong><code>myHeader</code></strong> with 
a value from a property placeholder, whose key is taken from a header named 
<strong><code>foo</code></strong>.</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[.setHeader(&quot;myHeader&quot;).groovy(&quot;context.resolvePropertyPlaceholders(&#39;{{&#39;
 + request.headers.get(&#39;foo&#39;) + &#39;}}&#39;)&quot;)
-]]></script>
-</div></div><p>From <strong>Camel 2.9</strong>: you can now use the properties 
function and the same example is simpler:</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[.setHeader(&quot;myHeader&quot;).groovy(&quot;properties.resolve(request.headers.get(&#39;foo&#39;))&quot;)
-]]></script>
-</div></div><h3 id="Groovy-LoadingScriptFromExternalResource">Loading Script 
From External Resource</h3><p><strong>Available from Camel 
2.11</strong></p><p>You can externalize the script and have Camel load it from 
a resource such as <strong><code>classpath:</code></strong>, 
<strong><code>file:</code></strong>, or <strong><code>http:</code></strong>. 
This is done using the following syntax: 
<strong><code>resource:scheme:location</code></strong> e.g. to refer to a file 
on the classpath you can do:</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[.setHeader(&quot;myHeader&quot;).groovy(&quot;resource:classpath:mygroovy.groovy&quot;)
-]]></script>
-</div></div><h3 id="Groovy-HowtoGettheResultfromMultipleStatementsScript">How 
to Get the Result from Multiple Statements Script</h3><p><strong>Available from 
Camel 2.14</strong></p><p>The script engine's eval method returns 
a&#160;<strong><code>null</code></strong> when it runs a multi-statement 
script. However, Camel can look up the value of a script's result by using the 
key <strong><code>result</code></strong> from the value set. When writing a 
multi-statement script set the value of 
the&#160;<strong><code>result</code></strong> variable as the script return 
value.</p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
-<script class="brush: text; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[bar = &quot;baz&quot;;
+</div></div><p></p><h3 
id="Groovy-ScriptContextOptions"><code>ScriptContext</code> 
Options</h3><p>&#160;</p><rich-text-body>The&#160;<code>JSR-223</code> 
scripting language's&#160;<strong><code>ScriptContext</code></strong> is 
pre-configured with the following attributes all set at 
<strong><code>ENGINE_SCOPE</code></strong>.</rich-text-body><div 
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" 
rowspan="1" class="confluenceTh"><p>Attribute</p></th><th colspan="1" 
rowspan="1" class="confluenceTh"><p>Type</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Value</p></th></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><span><code>camelContext</code><br 
clear="none"></span></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>org.apache.camel.CamelContext</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>The Camel 
Context.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>context</code
 ></p></td><td colspan="1" rowspan="1" 
 >class="confluenceTd"><p><code>org.apache.camel.CamelContext</code></p></td><td
 > colspan="1" rowspan="1" class="confluenceTd"><p>The Camel Context (cannot be 
 >used in groovy).</p></td></tr><tr><td colspan="1" rowspan="1" 
 >class="confluenceTd"><p><code>exchange</code></p></td><td colspan="1" 
 >rowspan="1" 
 >class="confluenceTd"><p><code>org.apache.camel.Exchange</code></p></td><td 
 >colspan="1" rowspan="1" class="confluenceTd"><p>The current 
 >Exchange.</p></td></tr><tr><td colspan="1" rowspan="1" 
 >class="confluenceTd"><p><code>properties</code></p></td><td colspan="1" 
 >rowspan="1" 
 >class="confluenceTd"><p><code>org.apache.camel.builder.script.PropertiesFunction</code></p></td><td
 > colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.9:</strong> 
 >Function with a <strong><code>resolve</code></strong> method to make it 
 >easier to use Camels <a shape="rect" href="properties.html">Properties</a> 
 >component from scripts. See further below for example.</p></td
 ></tr><tr><td colspan="1" rowspan="1" 
 >class="confluenceTd"><p><code>request</code></p></td><td colspan="1" 
 >rowspan="1" 
 >class="confluenceTd"><p><code>org.apache.camel.Message</code></p></td><td 
 >colspan="1" rowspan="1" 
 >class="confluenceTd"><p>The&#160;<strong><code>IN</code></strong> 
 >message.</p></td></tr><tr><td colspan="1" rowspan="1" 
 >class="confluenceTd"><p><code>response</code></p></td><td colspan="1" 
 >rowspan="1" 
 >class="confluenceTd"><p><code>org.apache.camel.Message</code></p></td><td 
 >colspan="1" rowspan="1" class="confluenceTd"><p><strong>Deprecated</strong>: 
 >The&#160;<strong><code>OUT</code></strong> message. 
 >The&#160;<strong><code>OUT</code></strong> message 
 >is&#160;<strong><code>null</code></strong> by default. Use the 
 ><strong><code>IN</code></strong> message 
 >instead.</p></td></tr></tbody></table></div><p>See <a shape="rect" 
 >href="scripting-languages.html">Scripting Languages</a> for the list of 
 >languages with explicit DSL support.</p><h3 
 >id="Groovy-PassingAdditionalArguments
 totheScriptingEngine">Passing Additional Arguments to 
the&#160;<code>ScriptingEngine</code></h3><p><strong>Available from Camel 
2.8</strong></p><p>You can provide additional arguments to the 
<strong><code>ScriptingEngine</code></strong> using a header on the Camel 
message with the key 
<strong><code>CamelScriptArguments</code></strong>.</p><p>Example:<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/JavaScriptExpressionTest.java}</plain-text-body></p><h3
 id="Groovy-UsingPropertiesFunction">Using Properties 
Function</h3><p><strong>Available from Camel 2.9</strong></p><p>If you need to 
use the <a shape="rect" href="properties.html">Properties</a> component from a 
script to lookup property placeholders, then its a bit cumbersome to do so. For 
example, to set a header name&#160;<strong><code>myHeader</code></strong> with 
a value from a property placeholder, whose key is taken from a header named 
<strong><code>f
 
oo</code></strong>.</p><plain-text-body>.setHeader("myHeader").groovy("context.resolvePropertyPlaceholders('{{'
 + request.headers.get('foo') + '}}')")
+</plain-text-body><p>From <strong>Camel 2.9</strong>: you can now use the 
properties function and the same example is simpler:</p><parameter 
ac:name="language">java</parameter><plain-text-body>.setHeader("myHeader").groovy("properties.resolve(request.headers.get('foo'))")
+</plain-text-body><h3 id="Groovy-LoadingScriptFromExternalResource">Loading 
Script From External Resource</h3><p><strong>Available from Camel 
2.11</strong></p><p>You can externalize the script and have Camel load it from 
a resource such as <strong><code>classpath:</code></strong>, 
<strong><code>file:</code></strong>, or <strong><code>http:</code></strong>. 
This is done using the following syntax: 
<strong><code>resource:scheme:location</code></strong> e.g. to refer to a file 
on the classpath you can do:</p><parameter 
ac:name="language">java</parameter><plain-text-body>.setHeader("myHeader").groovy("resource:classpath:mygroovy.groovy")
+</plain-text-body><h3 
id="Groovy-HowtoGettheResultfromMultipleStatementsScript">How to Get the Result 
from Multiple Statements Script</h3><p><strong>Available from Camel 
2.14</strong></p><p>The script engine's eval method returns 
a&#160;<strong><code>null</code></strong> when it runs a multi-statement 
script. However, Camel can look up the value of a script's result by using the 
key <strong><code>result</code></strong> from the value set. When writing a 
multi-statement script set the value of 
the&#160;<strong><code>result</code></strong> variable as the script return 
value.</p><parameter ac:name="language">text</parameter><plain-text-body>bar = 
"baz";
 # some other statements ... 
 # camel take the result value as the script evaluation result
 result = body * 2 + 1
-]]></script>
-</div></div><p>&#160;</p><h3 id="Groovy-Dependencies">Dependencies</h3><p>To 
use scripting languages in your camel routes you need to add the a dependency 
on <strong><code>camel-script</code></strong> which integrates the JSR-223 
scripting engine.</p><p>If you use maven you could just add the following to 
your <strong><code>pom.xml</code></strong>, substituting the version number for 
the latest &amp; greatest release (see <a shape="rect" href="download.html">the 
download page for the latest versions</a>).</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[&lt;dependency&gt;
+</plain-text-body><p>&#160;</p><h3 
id="Groovy-Dependencies">Dependencies</h3><p>To use scripting languages in your 
camel routes you need to add the a dependency on 
<strong><code>camel-script</code></strong> which integrates the JSR-223 
scripting engine.</p><p>If you use maven you could just add the following to 
your <strong><code>pom.xml</code></strong>, substituting the version number for 
the latest &amp; greatest release (see <a shape="rect" href="download.html">the 
download page for the latest versions</a>).</p><parameter 
ac:name="">xml</parameter><plain-text-body>&lt;dependency&gt;
   &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
   &lt;artifactId&gt;camel-script&lt;/artifactId&gt;
   &lt;version&gt;x.x.x&lt;/version&gt;
 &lt;/dependency&gt;
-]]></script>
-</div></div></div>
+</plain-text-body></div>
         </td>
         <td valign="top">
           <div class="navigation">

Modified: websites/production/camel/content/header.html
==============================================================================
--- websites/production/camel/content/header.html (original)
+++ websites/production/camel/content/header.html Fri Aug 25 08:22:01 2017
@@ -36,17 +36,6 @@
     <![endif]-->
 
 
-  <link href='//camel.apache.org/styles/highlighter/styles/shCoreCamel.css' 
rel='stylesheet' type='text/css' />
-  <link href='//camel.apache.org/styles/highlighter/styles/shThemeCamel.css' 
rel='stylesheet' type='text/css' />
-  <script src='//camel.apache.org/styles/highlighter/scripts/shCore.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushJava.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushXml.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushPlain.js' 
type='text/javascript'></script>
-  
-  <script type="text/javascript">
-  SyntaxHighlighter.defaults['toolbar'] = false;
-  SyntaxHighlighter.all();
-  </script>
 
     <title>
     Apache Camel: Header
@@ -94,34 +83,18 @@
 
 <p>The recipientList element of the Spring DSL can utilize a header expression 
like: </p>
 
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-&lt;route&gt;
-  &lt;from uri=&quot;direct:a&quot; /&gt;
-  &lt;!-- use comma as a delimiter for String based values --&gt;
-  &lt;recipientList delimiter=&quot;,&quot;&gt;
-    &lt;header&gt;myHeader&lt;/header&gt;
-  &lt;/recipientList&gt;
-&lt;/route&gt;
-]]></script>
-</div></div>
+<plain-text-body>{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/recipientListWithStringDelimitedHeader.xml}</plain-text-body>
 
 <p>In this case, the list of recipients are contained in the header 
'myHeader'. </p>
 
 <p>And the same example in Java DSL:</p>
 
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-from(&quot;direct:a&quot;).recipientList(header(&quot;myHeader&quot;));
-]]></script>
-</div></div>
+<plain-text-body>{snippet:id=example|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListWithStringDelimitedHeaderTest.java}</plain-text-body>
 
 <p>And with a slightly different syntax where you use the builder to the 
fullest (i.e. avoid using parameters but using stacked operations, notice that 
header is not a parameter but a stacked method call)</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-  from(&quot;direct:a&quot;).recipientList().header(&quot;myHeader&quot;);
-]]></script>
-</div></div>
+<parameter ac:name="">java</parameter><plain-text-body>
+  from("direct:a").recipientList().header("myHeader");
+</plain-text-body>
 
 <h3 id="Header-Dependencies">Dependencies</h3>
 <p>The Header language is part of <strong>camel-core</strong>.</p></div>


Reply via email to