You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bu...@apache.org on 2015/10/20 20:20:04 UTC
svn commit: r969642 - in /websites/production/camel/content:
cache/main.pageCache graceful-shutdown.html
Author: buildbot
Date: Tue Oct 20 18:20:04 2015
New Revision: 969642
Log:
Production update by buildbot for camel
Modified:
websites/production/camel/content/cache/main.pageCache
websites/production/camel/content/graceful-shutdown.html
Modified: websites/production/camel/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.
Modified: websites/production/camel/content/graceful-shutdown.html
==============================================================================
--- websites/production/camel/content/graceful-shutdown.html (original)
+++ websites/production/camel/content/graceful-shutdown.html Tue Oct 20 18:20:04 2015
@@ -99,13 +99,13 @@
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.getShutdownStrategegy().setSuppressLoggingOnTimeout(true);
+<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 <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;"> 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.getShutdownStrategegy().setLogInflightExchangesOnTimeout(false);
+<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[
@@ -126,7 +126,7 @@ public void configure() throws Exception
.to("mock:bar");
}
]]></script>
-</div></div><p>The same route in Spring XML would be:</p><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), how
ever 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:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</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("foo").noAutoStartup()
@@ -136,7 +136,7 @@ public void configure() throws Exception
.to("mock:bar");
}
]]></script>
-</div></div><p>The same route in Spring XML would be:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</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[
<camelContext xmlns="http://camel.apache.org/schema/spring">
<!-- let this route complete all its pending messages when asked to shutdown -->