Modified: websites/production/camel/content/book-pattern-appendix.html
==============================================================================
--- websites/production/camel/content/book-pattern-appendix.html (original)
+++ websites/production/camel/content/book-pattern-appendix.html Fri Apr 17
11:20:03 2015
@@ -452,7 +452,7 @@ RouteBuilder builder = new RouteBuilder(
<p class="title">Difference between Dead Letter Channel
and Default Error Handler</p>
<span class="aui-icon icon-success">Icon</span>
<div class="message-content">
- <p>The major difference is that <a shape="rect"
href="dead-letter-channel.html">Dead Letter Channel</a> has a dead letter queue
that whenever an <a shape="rect" href="exchange.html">Exchange</a> could not be
processed is moved to. It will <strong>always</strong> move failed exchanges to
this queue.</p><p>Unlike the <a shape="rect"
href="defaulterrorhandler.html">Default Error Handler</a> that does
<strong>not</strong> have a dead letter queue. So whenever an <a shape="rect"
href="exchange.html">Exchange</a> could not be processed the error is
propagated back to the client.</p><p><strong>Notice:</strong> You can adjust
this behavior of whether the client should be notified or not with the
<strong>handled</strong> option.</p><p>When the DeadLetterChannel moves a
message to the dead letter endpoint, then if any new exceptions is thrown
during that process, then by default the dead letter channel will handle the
new exception as well. This ensures that the De
adLetterChannel will always succeed. From <strong>Camel 2.15</strong> onwards
this behavior can be changed by setting the option
deadLetterHandleNewException=false. Then if a new exception is thrown, then the
dead letter channel will fail and propagate back that new exception (which is
the behavior of the default error handler). When a new exception occurs then
the dead letter channel logs this at WARN level. This can be turned off by
setting logNewException=false.</p>
+ <p>The Default Error Handler does very little: it
ends the Exchange immediately and propagates the thrown Exception back to the
caller.</p><p>The Dead Letter Channel lets you control behaviors including
redelivery, whether to propagate the thrown Exception to the caller (the
<strong>handled</strong> option), and where the (failed) Exchange should now be
routed to.</p><p>When the DeadLetterChannel moves a message to the dead letter
endpoint, any new Exception thrown is by default handled by the dead letter
channel as well. This ensures that the DeadLetterChannel will always succeed.
From <strong>Camel 2.15</strong> onwards this behavior can be changed by
setting the option deadLetterHandleNewException=false. Then if a new Exception
is thrown, then the dead letter channel will fail and propagate back that new
Exception (which is the behavior of the default error handler). When a new
Exception occurs then the dead letter channel logs this at WARN level. This
can be turned off by setting logNewException=false.</p>
</div>
</div>
<h3 id="BookPatternAppendix-Redelivery">Redelivery</h3><p>It is common for a
temporary outage or database deadlock to cause a message to fail to process;
but the chances are if its tried a few more times with some time delay then it
will complete fine. So we typically wish to use some kind of redelivery policy
to decide how many times to try redeliver a message and how long to wait before
redelivery attempts.</p><p>The <a shape="rect" class="external-link"
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/RedeliveryPolicy.html">RedeliveryPolicy</a>
defines how the message is to be redelivered. You can customize things
like</p><ul><li>how many times a message is attempted to be redelivered before
it is considered a failure and sent to the dead letter channel</li><li>the
initial redelivery timeout</li><li>whether or not exponential backoff is used
(i.e. the time between retries increases using a backoff
multiplier)</li><li>whether to use collisi
on avoidance to add some randomness to the timings</li><li>delay pattern (see
below for details)</li><li><strong>Camel 2.11:</strong> whether to allow
redelivery during stopping/shutdown</li></ul><p>Once all attempts at
redelivering the message fails then the message is forwarded to the dead letter
queue.</p><h3
id="BookPatternAppendix-AboutmovingExchangetodeadletterqueueandusinghandled">About
moving Exchange to dead letter queue and using
handled</h3><p><strong>Handled</strong> on <a shape="rect"
href="dead-letter-channel.html">Dead Letter Channel</a></p><p>When all attempts
of redelivery have failed the <a shape="rect" href="exchange.html">Exchange</a>
is moved to the dead letter queue (the dead letter endpoint). The exchange is
then complete and from the client point of view it was processed. As such the
<a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a> have
handled the <a shape="rect" href="exchange.html">Exchange</a>.</p><p>For
instance configuring the dea
d letter channel as:</p><p><strong>Using the <a shape="rect"
href="fluent-builders.html">Fluent Builders</a></strong></p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
@@ -612,7 +612,7 @@ public class MyRedeliverProcessor implem
}
}
]]></script>
-</div></div><p></p><h4 id="BookPatternAppendix-UsingThisPattern.8">Using This
Pattern</h4>
+</div></div><h3
id="BookPatternAppendix-HowcanIlogwhatcausedtheDeadLetterChanneltobeinvoked?">How
can I log what caused the Dead Letter Channel to be invoked?</h3><p>You often
need to know what went wrong that caused the Dead Letter Channel to be used and
it does not offer logging for this purpose. So the Dead Letter Channel's
endpoint can be set to a endpoint of our own (such
as <code>direct:deadLetterChannel</code>). We write a route to accept this
Exchange and log the Exception, then forward on to where we want the failed
Exchange moved to (which might be a DLQ queue for instance). See also <a
shape="rect" class="external-link"
href="http://stackoverflow.com/questions/13711462/logging-camel-exceptions-and-sending-to-the-dead-letter-channel"
rel="nofollow">http://stackoverflow.com/questions/13711462/logging-camel-exceptions-and-sending-to-the-dead-letter-channel</a></p><p></p><h4
id="BookPatternAppendix-UsingThisPattern.8">Using This Pattern</h4>
<p>If you would like to use this EIP Pattern then please read the <a
shape="rect" href="getting-started.html">Getting Started</a>, you may also find
the <a shape="rect" href="architecture.html">Architecture</a> useful
particularly the description of <a shape="rect"
href="endpoint.html">Endpoint</a> and <a shape="rect"
href="uris.html">URIs</a>. Then you could try out some of the <a shape="rect"
href="examples.html">Examples</a> first before trying this pattern out.</p><ul
class="alternate"><li><a shape="rect" href="error-handler.html">Error
Handler</a></li><li><a shape="rect" href="exception-clause.html">Exception
Clause</a></li></ul>
<h3 id="BookPatternAppendix-GuaranteedDelivery">Guaranteed
Delivery</h3><p>Camel supports the <a shape="rect" class="external-link"
href="http://www.enterpriseintegrationpatterns.com/GuaranteedMessaging.html"
rel="nofollow">Guaranteed Delivery</a> from the <a shape="rect"
href="enterprise-integration-patterns.html">EIP patterns</a> using among others
the following components:</p><ul><li><a shape="rect" href="file2.html">File</a>
for using file systems as a persistent store of messages</li><li><a
shape="rect" href="jms.html">JMS</a> when using persistent delivery (the
default) for working with JMS Queues and Topics for high performance,
clustering and load balancing</li><li><a shape="rect" href="jpa.html">JPA</a>
for using a database as a persistence layer, or use any of the many other
database component such as <a shape="rect" href="sql.html">SQL</a>, <a
shape="rect" href="jdbc.html">JDBC</a>, <a shape="rect"
href="ibatis.html">iBATIS</a>/<a shape="rect" href="mybatis.html">MyBatis<
/a>, <a shape="rect" href="hibernate.html">Hibernate</a></li><li><a
shape="rect" href="hawtdb.html">HawtDB</a> for a lightweight key-value
persistent store</li></ul><p><img class="confluence-embedded-image
confluence-external-resource"
src="http://www.enterpriseintegrationpatterns.com/img/GuaranteedMessagingSolution.gif"
data-image-src="http://www.enterpriseintegrationpatterns.com/img/GuaranteedMessagingSolution.gif"></p><h4
id="BookPatternAppendix-Example.1">Example</h4><p>The following example
demonstrates illustrates the use of <a shape="rect" class="external-link"
href="http://www.enterpriseintegrationpatterns.com/GuaranteedMessaging.html"
rel="nofollow">Guaranteed Delivery</a> within the <a shape="rect"
href="jms.html">JMS</a> component. By default, a message is not considered
successfully delivered until the recipient has persisted the message locally
guaranteeing its receipt in the event the destination becomes
unavailable.</p><p><strong>Using the <a
shape="rect" href="fluent-builders.html">Fluent Builders</a></strong></p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
Modified: websites/production/camel/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.
Modified: websites/production/camel/content/camel-test.html
==============================================================================
--- websites/production/camel/content/camel-test.html (original)
+++ websites/production/camel/content/camel-test.html Fri Apr 17 11:20:03 2015
@@ -86,54 +86,30 @@
<tbody>
<tr>
<td valign="top" width="100%">
-<div class="wiki-content maincontent"><h2 id="CamelTest-CamelTest">Camel
Test</h2>
-
-<p>As a simple alternative to using <a shape="rect"
href="spring-testing.html">Spring Testing</a> or <a shape="rect"
href="guice.html">Guice</a> the <strong>camel-test</strong> module was
introduced so you can perform powerful <a shape="rect"
href="testing.html">Testing</a> of your <a shape="rect"
href="enterprise-integration-patterns.html">Enterprise Integration Patterns</a>
easily.</p>
-
- <div class="aui-message hint shadowed information-macro">
+<div class="wiki-content maincontent"><h2 id="CamelTest-CamelTest">Camel
Test</h2><p>As a simple alternative to using <a shape="rect"
href="spring-testing.html">Spring Testing</a> or <a shape="rect"
href="guice.html">Guice</a> the <strong>camel-test</strong> module was
introduced so you can perform powerful <a shape="rect"
href="testing.html">Testing</a> of your <a shape="rect"
href="enterprise-integration-patterns.html">Enterprise Integration Patterns</a>
easily.</p> <div class="aui-message hint shadowed information-macro">
<span class="aui-icon icon-hint">Icon</span>
<div class="message-content">
-
-<p>The <code>camel-test</code> JAR is using JUnit. There is an alternative
<code>camel-testng</code> JAR (Camel 2.8 onwards) using the <a shape="rect"
class="external-link" href="http://testng.org/doc/index.html"
rel="nofollow">TestNG</a> test framework.</p>
+ <p>The <code>camel-test</code> JAR is using JUnit.
There is an alternative <code>camel-testng</code> JAR (Camel 2.8 onwards) using
the <a shape="rect" class="external-link"
href="http://testng.org/doc/index.html" rel="nofollow">TestNG</a> test
framework.</p>
</div>
</div>
-
-
-<h3 id="CamelTest-Addingtoyourpom.xml">Adding to your pom.xml</h3>
-
-<p>To get started using Camel Test you will need to add an entry to your
pom.xml</p>
-
-<h4 id="CamelTest-JUnit">JUnit</h4>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[
-<dependency>
+<h3 id="CamelTest-Addingtoyourpom.xml">Adding to your pom.xml</h3><p>To get
started using Camel Test you will need to add an entry to your pom.xml</p><h4
id="CamelTest-JUnit">JUnit</h4><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test</artifactId>
<version>${camel-version}</version>
<scope>test</scope>
</dependency>
]]></script>
-</div></div>
-
-<h4 id="CamelTest-TestNG">TestNG</h4>
-
-<p><strong>Available as of Camel 2.8</strong></p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[
-<dependency>
+</div></div><h4 id="CamelTest-TestNG">TestNG</h4><p><strong>Available as of
Camel 2.8</strong></p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-testng</artifactId>
<version>${camel-version}</version>
<scope>test</scope>
</dependency>
]]></script>
-</div></div>
-
-<p>You might also want to add slf4j and log4j to ensure nice logging messages
(and maybe adding a <a shape="rect" class="external-link"
href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-test/src/test/resources/log4j.properties">log4j.properties</a>
file into your src/test/resources directory).</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[
-<dependency>
+</div></div><p>You might also want to add slf4j and log4j to ensure nice
logging messages (and maybe adding a <a shape="rect" class="external-link"
href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-test/src/test/resources/log4j.properties">log4j.properties</a>
file into your src/test/resources directory).</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>test</scope>
@@ -144,15 +120,7 @@
<scope>test</scope>
</dependency>
]]></script>
-</div></div>
-
-<h3 id="CamelTest-Writingyourtest">Writing your test</h3>
-
-<p>You firstly need to derive from the class
<strong>CamelTestSupport</strong> (org.apache.camel.test.CamelTestSupport,
org.apache.camel.test.junit4.CamelTestSupport, or
org.apache.camel.testng.CamelTestSupport for JUnit 3.x, JUnit 4.x, and TestNG,
respectively) and typically you will need to override the
<strong>createRouteBuilder()</strong>
or <strong>createRouteBuilders()</strong> method to create routes to
be tested.</p>
-
-<p>Here is an <a shape="rect" class="external-link"
href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-test/src/test/java/org/apache/camel/test/patterns/FilterTest.java">example</a>.</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+</div></div><h3 id="CamelTest-Writingyourtest">Writing your test</h3><p>You
firstly need to derive from the class
<strong>CamelTestSupport</strong> (org.apache.camel.test.CamelTestSupport,
org.apache.camel.test.junit4.CamelTestSupport, or
org.apache.camel.testng.CamelTestSupport for JUnit 3.x, JUnit 4.x, and TestNG,
respectively) and typically you will need to override the
<strong>createRouteBuilder()</strong>
or <strong>createRouteBuilders()</strong> method to create routes to
be tested.</p><p>Here is an <a shape="rect" class="external-link"
href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-test/src/test/java/org/apache/camel/test/patterns/FilterTest.java">example</a>.</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
public class FilterTest extends CamelTestSupport {
@@ -192,49 +160,14 @@ public class FilterTest extends CamelTes
}
}
]]></script>
-</div></div>
-
-<p>Notice how you can use the various <a shape="rect"
href="bean-integration.html">Camel binding and injection annotations</a> to
inject individual <a shape="rect" href="endpoint.html">Endpoint</a> objects -
particularly the <a shape="rect" href="mock.html">Mock endpoints</a> which are
very useful for <a shape="rect" href="testing.html">Testing</a>. Also you can
inject <a shape="rect" href="pojo-producing.html">producer objects such as
ProducerTemplate or some application code interface</a> for sending messages or
invoking services.</p>
-
-<h4 id="CamelTest-FeaturesProvidedbyCamelTestSupport">Features Provided by
CamelTestSupport</h4>
-
-<p>The various <strong>CamelTestSupport</strong> classes provide a standard
set of behaviors relating to the CamelContext used to host the route(s) under
test.  The classes provide a number of methods that allow a test to alter
the configuration of the CamelContext used.  The following table describes
the available customization methods and the default behavior of tests that are
built from a <strong>CamelTestSupport</strong> class.</p>
-<div class="table-wrap"><table class="confluenceTable"><tbody><tr><th
colspan="1" rowspan="1" class="confluenceTh"><p> Method Name </p></th><th
colspan="1" rowspan="1" class="confluenceTh"><p> Description </p></th><th
colspan="1" rowspan="1" class="confluenceTh"><p> Default Behavior
</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> boolean
isUseRouteBuilder() </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> If the route builders from returned
from <strong>createRouteBuilder()</strong> or
<strong>createRouteBuilders()</strong> should be added to the CamelContext used
in the test should be started. </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> Returns true.
 <strong>createRouteBuilder()</strong> or <strong>createRouteBuilders()</strong>
are invoked and the CamelContext is started automatically.
</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> boolean
isUseAdviceWith() <br clear="none" class="at
l-forced-newline"> </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> If the CamelContext use in the test should be
automatically started before test methods are invoked. <br clear="none"
class="atl-forced-newline">
-Override when using <a shape="rect" href="advicewith.html">advice
with</a> and return true.  This helps in knowing the adviceWith is to
be used, and the CamelContext will not be started before the
advice with takes place. This delay helps by ensuring the advice with has been
property setup before the CamelContext is started.</p>
- <div class="aui-message hint shadowed information-macro">
+</div></div><p>Notice how you can use the various <a shape="rect"
href="bean-integration.html">Camel binding and injection annotations</a> to
inject individual <a shape="rect" href="endpoint.html">Endpoint</a> objects -
particularly the <a shape="rect" href="mock.html">Mock endpoints</a> which are
very useful for <a shape="rect" href="testing.html">Testing</a>. Also you can
inject <a shape="rect" href="pojo-producing.html">producer objects such as
ProducerTemplate or some application code interface</a> for sending messages or
invoking services.</p><h4
id="CamelTest-FeaturesProvidedbyCamelTestSupport">Features Provided by
CamelTestSupport</h4><p>The various <strong>CamelTestSupport</strong> classes
provide a standard set of behaviors relating to the CamelContext used to host
the route(s) under test.  The classes provide a number of methods that
allow a test to alter the configuration of the CamelContext used.  The
following table describes the available customization method
s and the default behavior of tests that are built from
a <strong>CamelTestSupport</strong> class.</p><div
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1"
rowspan="1" class="confluenceTh"><p>Method Name</p></th><th colspan="1"
rowspan="1" class="confluenceTh"><p>Description</p></th><th colspan="1"
rowspan="1" class="confluenceTh"><p>Default Behavior</p></th></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><p>boolean
isUseRouteBuilder()</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>If the route builders from returned
from <strong>createRouteBuilder()</strong> or
<strong>createRouteBuilders()</strong> should be added to the CamelContext used
in the test should be started.</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Returns true.
 <strong>createRouteBuilder()</strong> or <strong>createRouteBuilders()</strong>
are invoked and the CamelContext is started
automatically.</p></td></tr><tr><td colspa
n="1" rowspan="1" class="confluenceTd"><p>boolean
isUseAdviceWith()</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>If the CamelContext use in the test should be
automatically started before test methods are invoked. <br clear="none"
class="atl-forced-newline"> Override when using <a shape="rect"
href="advicewith.html">advice with</a> and return true.  This helps
in knowing the adviceWith is to be used, and the CamelContext will
not be started before the advice with takes place. This delay helps by
ensuring the advice with has been property setup before
the CamelContext is started.</p> <div class="aui-message hint
shadowed information-macro">
<span class="aui-icon icon-hint">Icon</span>
<div class="message-content">
<p>Its important to start the CamelContext
manually from the unit test after you are done doing all the advice with.</p>
</div>
</div>
-
-<p><br clear="none" class="atl-forced-newline"> </p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p> Returns false.  the CamelContext is
started automatically before test methods are invoked. </p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><p> boolean
isCreateCamelContextPerClass() <br clear="none" class="atl-forced-newline">
</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> See <a
shape="rect"
href="#CamelTest-SetupCamelContextonceperclass,orpereverytestmethod">Setup
CamelContext once per class, or per every test method</a>. </p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p> The CamelContext and routes
are recreated for each test method. </p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p> String isMockEndpoints() </p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p> Triggers the auto-mocking of
endpoints whose URIs match the provided filter.  The default filter
is null which disables t
his feature.  Return "*"  to match all endpoints.
 See org.apache.camel.impl.InterceptSendToMockEndpointStrategy for more
details on the registration of the mock endpoints. </p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p> Disabled </p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p> boolean isUseDebugger() </p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p> If this method returns true,
the <strong>debugBefore(Exchange exchange, Processor processor,
ProcessorDefinition<?> definition, String id, String
label)</strong> and <br clear="none" class="atl-forced-newline">
-<strong>debugAfter(Exchange exchange, Processor processor,
ProcessorDefinition<?> definition, String id, String label, long
timeTaken)</strong> methods are invoked for each processor in the
registered routes. </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> Disabled.  The methods are not invoked during the
test. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>
int getShutdownTimeout() </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> Returns the number of seconds that Camel should wait
for graceful shutdown.  Useful for decreasing test times when a message is
still in flight at the end of the test. </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> Returns 10 seconds. </p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p> boolean useJmx() </p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p> If JMX should be disabled on the
CamelContext used in the test. </p></td><td colspan="
1" rowspan="1" class="confluenceTd"><p> JMX is disabled. </p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><p> JndiRegistry createRegistry()
<br clear="none" class="atl-forced-newline"> </p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p> Provides a hook for adding objects into
the registry.  Override this method to bind objects to the registry before
test methods are invoked. </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> An empty registry is initialized.
</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>
useOverridePropertiesWithPropertiesComponent </p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p> <strong>Camel 2.10:</strong> Allows to
add/override properties when <a shape="rect"
href="using-propertyplaceholder.html">Using PropertyPlaceholder</a> in Camel.
</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> null
</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>
ignoreMissin
gLocationWithPropertiesComponent </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p> <strong>Camel 2.10:</strong> Allows to control if
Camel should ignore missing locations for properties. </p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p> null </p></td></tr></tbody></table></div>
-
-
-<h3 id="CamelTest-JNDI">JNDI</h3>
-
-<p>Camel uses a <a shape="rect" href="registry.html">Registry</a> to allow you
to configure <a shape="rect" href="component.html">Component</a> or <a
shape="rect" href="endpoint.html">Endpoint</a> instances or <a shape="rect"
href="bean-integration.html">Beans used in your routes</a>. If you are not
using <a shape="rect" href="spring.html">Spring</a> or <a shape="rect"
class="unresolved" href="#">OSGi</a> then <a shape="rect"
href="jndi.html">JNDI</a> is used as the default registry implementation.</p>
-
-<p>So you will also need to create a <strong>jndi.properties</strong> file in
your <strong>src/test/resources</strong> directory so that there is a default
registry available to initialise the <a shape="rect"
href="camelcontext.html">CamelContext</a>.</p>
-
-<p>Here is <a shape="rect" class="external-link"
href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-test/src/test/resources/jndi.properties">an
example jndi.properties file</a></p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
-java.naming.factory.initial =
org.apache.camel.util.jndi.CamelInitialContextFactory
-]]></script>
-</div></div>
-
-<h3 id="CamelTest-Dynamicallyassigningports">Dynamically assigning ports</h3>
-
-<p><strong>Available as of Camel 2.7</strong></p>
-
-<p>Tests that use port numbers will fail if that port is already on use.
<code>AvailablePortFinder</code> provides methods for finding unused port
numbers at runtime.</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
-// Get the next available port number starting from the default starting port
of 1024
+</td><td colspan="1" rowspan="1" class="confluenceTd"><p>Returns false.
 the CamelContext is started automatically before test methods are
invoked.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>boolean isCreateCamelContextPerClass()</p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>See <a shape="rect"
href="#CamelTest-SetupCamelContextonceperclass,orpereverytestmethod">Setup
CamelContext once per class, or per every test method</a>.</p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>The CamelContext and routes are
recreated for each test method.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>String isMockEndpoints()</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Triggers the auto-mocking of endpoints
whose URIs match the provided filter.  The default filter is null
which disables this feature.  Return "*"  to match all endpoints.
 See org.apache.camel.impl.InterceptSe
ndToMockEndpointStrategy for more details on the registration of the
mock endpoints.</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Disabled</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>boolean isUseDebugger()</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>If this method returns true,
the <strong>debugBefore(Exchange exchange, Processor processor,
ProcessorDefinition<?> definition, String id, String
label)</strong> and <br clear="none" class="atl-forced-newline">
<strong>debugAfter(Exchange exchange, Processor processor,
ProcessorDefinition<?> definition, String id, String label, long
timeTaken)</strong> methods are invoked for each processor in the
registered routes.</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Disabled.  The methods are not invoked during the
test.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>int
getShutdownTimeout()</p>
</td><td colspan="1" rowspan="1" class="confluenceTd"><p>Returns the number of
seconds that Camel should wait for graceful shutdown.  Useful for
decreasing test times when a message is still in flight at the end of the
test.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Returns 10
seconds.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>boolean useJmx()</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>If JMX should be disabled on the CamelContext used in
the test.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>JMX is
disabled.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>JndiRegistry createRegistry()</p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Provides a hook for adding objects into the
registry.  Override this method to bind objects to the registry before
test methods are invoked.</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>An empty registry is initialized.</
p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>useOverridePropertiesWithPropertiesComponent</p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong>
Allows to add/override properties when <a shape="rect"
href="using-propertyplaceholder.html">Using PropertyPlaceholder</a> in
Camel.</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>null</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>ignoreMissingLocationWithPropertiesComponent</p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong>
Allows to control if Camel should ignore missing locations for
properties.</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>null</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd">boolean isDumpRouteStats</td><td colspan="1" rowspan="1"
class="confluenceTd"><strong>Camel 2.16:</strong> If enabled, then Camel will
dump all route statistics into XML files in the targe
t/camel-route-stats directory. These XML files contains information about
"route coverage" of all the routes that was used during the unit test. This
allows tooling to inspect these XML files and generate nice route coverage
reports.</td><td colspan="1" rowspan="1"
class="confluenceTd">Disabled.</td></tr></tbody></table></div><h3
id="CamelTest-JNDI">JNDI</h3><p>Camel uses a <a shape="rect"
href="registry.html">Registry</a> to allow you to configure <a shape="rect"
href="component.html">Component</a> or <a shape="rect"
href="endpoint.html">Endpoint</a> instances or <a shape="rect"
href="bean-integration.html">Beans used in your routes</a>. If you are not
using <a shape="rect" href="spring.html">Spring</a> or <a shape="rect"
class="unresolved" href="#">OSGi</a> then <a shape="rect"
href="jndi.html">JNDI</a> is used as the default registry
implementation.</p><p>So you will also need to create a
<strong>jndi.properties</strong> file in your
<strong>src/test/resources</strong> directory
so that there is a default registry available to initialise the <a
shape="rect" href="camelcontext.html">CamelContext</a>.</p><p>Here is <a
shape="rect" class="external-link"
href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-test/src/test/resources/jndi.properties">an
example jndi.properties file</a></p><h3
id="CamelTest-Dynamicallyassigningports">Dynamically assigning
ports</h3><p><strong>Available as of Camel 2.7</strong></p><p>Tests that use
port numbers will fail if that port is already on use.
<code>AvailablePortFinder</code> provides methods for finding unused port
numbers at runtime.</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[// Get the next available port number
starting from the default starting port of 1024
int port1 = AvailablePortFinder.getNextAvailable();
/*
* Get another port. Note that just getting a port number does not reserve it
so
@@ -242,38 +175,21 @@ int port1 = AvailablePortFinder.getNextA
*/
int port2 = AvailablePortFinder.getNextAvailable(port1 + 1);
]]></script>
-</div></div>
-
-
-<h3 id="CamelTest-SetupCamelContextonceperclass,orpereverytestmethod">Setup
CamelContext once per class, or per every test method</h3>
-
-<p><strong>Available as of Camel 2.8</strong></p>
-
-<p>The <a shape="rect" href="camel-test.html">Camel Test</a> kit will by
default setup and shutdown <a shape="rect"
href="camelcontext.html">CamelContext</a> per every test method in your test
class. So for example if you have 3 test methods, then <a shape="rect"
href="camelcontext.html">CamelContext</a> is started and shutdown after each
test, that is 3 times.</p>
-
- <div class="aui-message success shadowed information-macro">
+</div></div><h3
id="CamelTest-SetupCamelContextonceperclass,orpereverytestmethod">Setup
CamelContext once per class, or per every test method</h3><p><strong>Available
as of Camel 2.8</strong></p><p>The <a shape="rect" href="camel-test.html">Camel
Test</a> kit will by default setup and shutdown <a shape="rect"
href="camelcontext.html">CamelContext</a> per every test method in your test
class. So for example if you have 3 test methods, then <a shape="rect"
href="camelcontext.html">CamelContext</a> is started and shutdown after each
test, that is 3 times.</p> <div class="aui-message success shadowed
information-macro">
<p class="title">TestNG</p>
<span class="aui-icon icon-success">Icon</span>
<div class="message-content">
-
-<p>This feature is also supported in camel-testng</p>
+ <p>This feature is also supported in
camel-testng</p>
</div>
</div>
-
-
<div class="aui-message problem shadowed information-macro">
<p class="title">Beware</p>
<span class="aui-icon icon-problem">Icon</span>
<div class="message-content">
-
-<p>When using this the <a shape="rect"
href="camelcontext.html">CamelContext</a> will keep state between tests, so
have that in mind. So if your unit tests start to fail for no apparent reason,
it could be due this fact. So use this feature with a bit of care.</p>
+ <p>When using this the <a shape="rect"
href="camelcontext.html">CamelContext</a> will keep state between tests, so
have that in mind. So if your unit tests start to fail for no apparent reason,
it could be due this fact. So use this feature with a bit of care.</p>
</div>
</div>
-
-
-<p>You may want to do this once, to share the <a shape="rect"
href="camelcontext.html">CamelContext</a> between test methods, to speedup unit
testing. This requires to use JUnit 4! In your unit test method you have to
extend the <code>org.apache.camel.test.junit4.CamelTestSupport</code> or the
<code>org.apache.camel.test.junit4.CamelSpringTestSupport</code> test class and
override the <code>isCreateCamelContextPerClass</code> method and return
<code>true</code> as shown in the following example:</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader
panelHeader pdl" style="border-bottom-width: 1px;"><b>Setup CamelContext once
per class</b></div><div class="codeContent panelContent pdl">
+<p>You may want to do this once, to share the <a shape="rect"
href="camelcontext.html">CamelContext</a> between test methods, to speedup unit
testing. This requires to use JUnit 4! In your unit test method you have to
extend the <code>org.apache.camel.test.junit4.CamelTestSupport</code> or the
<code>org.apache.camel.test.junit4.CamelSpringTestSupport</code> test class and
override the <code>isCreateCamelContextPerClass</code> method and return
<code>true</code> as shown in the following example:</p><div class="code panel
pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl"
style="border-bottom-width: 1px;"><b>Setup CamelContext once per
class</b></div><div class="codeContent panelContent pdl">
<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
public class FilterCreateCamelContextPerClassTest extends CamelTestSupport {
@@ -315,12 +231,10 @@ public class FilterCreateCamelContextPer
}
}
]]></script>
-</div></div>
-
-
-<h3 id="CamelTest-SeeAlso">See Also</h3>
-
-<ul><li><a shape="rect" href="testing.html">Testing</a></li><li><a
shape="rect" href="mock.html">Mock</a></li><li><a shape="rect"
href="test.html">Test</a></li></ul></div>
+</div></div><h3 id="CamelTest-SeeAlso">See Also</h3><ul><li><a shape="rect"
href="testing.html">Testing</a></li><li><a shape="rect"
href="mock.html">Mock</a></li><li><a shape="rect"
href="test.html">Test</a></li></ul><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[java.naming.factory.initial =
org.apache.camel.util.jndi.CamelInitialContextFactory
+]]></script>
+</div></div></div>
</td>
<td valign="top">
<div class="navigation">
Modified: websites/production/camel/content/dead-letter-channel.html
==============================================================================
--- websites/production/camel/content/dead-letter-channel.html (original)
+++ websites/production/camel/content/dead-letter-channel.html Fri Apr 17
11:20:03 2015
@@ -90,7 +90,7 @@
<p class="title">Difference between Dead Letter Channel
and Default Error Handler</p>
<span class="aui-icon icon-success">Icon</span>
<div class="message-content">
- <p>The major difference is that <a shape="rect"
href="dead-letter-channel.html">Dead Letter Channel</a> has a dead letter queue
that whenever an <a shape="rect" href="exchange.html">Exchange</a> could not be
processed is moved to. It will <strong>always</strong> move failed exchanges to
this queue.</p><p>Unlike the <a shape="rect"
href="defaulterrorhandler.html">Default Error Handler</a> that does
<strong>not</strong> have a dead letter queue. So whenever an <a shape="rect"
href="exchange.html">Exchange</a> could not be processed the error is
propagated back to the client.</p><p><strong>Notice:</strong> You can adjust
this behavior of whether the client should be notified or not with the
<strong>handled</strong> option.</p><p>When the DeadLetterChannel moves a
message to the dead letter endpoint, then if any new exceptions is thrown
during that process, then by default the dead letter channel will handle the
new exception as well. This ensures that the De
adLetterChannel will always succeed. From <strong>Camel 2.15</strong> onwards
this behavior can be changed by setting the option
deadLetterHandleNewException=false. Then if a new exception is thrown, then the
dead letter channel will fail and propagate back that new exception (which is
the behavior of the default error handler). When a new exception occurs then
the dead letter channel logs this at WARN level. This can be turned off by
setting logNewException=false.</p>
+ <p>The Default Error Handler does very little: it
ends the Exchange immediately and propagates the thrown Exception back to the
caller.</p><p>The Dead Letter Channel lets you control behaviors including
redelivery, whether to propagate the thrown Exception to the caller (the
<strong>handled</strong> option), and where the (failed) Exchange should now be
routed to.</p><p>When the DeadLetterChannel moves a message to the dead letter
endpoint, any new Exception thrown is by default handled by the dead letter
channel as well. This ensures that the DeadLetterChannel will always succeed.
From <strong>Camel 2.15</strong> onwards this behavior can be changed by
setting the option deadLetterHandleNewException=false. Then if a new Exception
is thrown, then the dead letter channel will fail and propagate back that new
Exception (which is the behavior of the default error handler). When a new
Exception occurs then the dead letter channel logs this at WARN level. This
can be turned off by setting logNewException=false.</p>
</div>
</div>
<h3 id="DeadLetterChannel-Redelivery">Redelivery</h3><p>It is common for a
temporary outage or database deadlock to cause a message to fail to process;
but the chances are if its tried a few more times with some time delay then it
will complete fine. So we typically wish to use some kind of redelivery policy
to decide how many times to try redeliver a message and how long to wait before
redelivery attempts.</p><p>The <a shape="rect" class="external-link"
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/RedeliveryPolicy.html">RedeliveryPolicy</a>
defines how the message is to be redelivered. You can customize things
like</p><ul><li>how many times a message is attempted to be redelivered before
it is considered a failure and sent to the dead letter channel</li><li>the
initial redelivery timeout</li><li>whether or not exponential backoff is used
(i.e. the time between retries increases using a backoff
multiplier)</li><li>whether to use collision
avoidance to add some randomness to the timings</li><li>delay pattern (see
below for details)</li><li><strong>Camel 2.11:</strong> whether to allow
redelivery during stopping/shutdown</li></ul><p>Once all attempts at
redelivering the message fails then the message is forwarded to the dead letter
queue.</p><h3
id="DeadLetterChannel-AboutmovingExchangetodeadletterqueueandusinghandled">About
moving Exchange to dead letter queue and using
handled</h3><p><strong>Handled</strong> on <a shape="rect"
href="dead-letter-channel.html">Dead Letter Channel</a></p><p>When all attempts
of redelivery have failed the <a shape="rect" href="exchange.html">Exchange</a>
is moved to the dead letter queue (the dead letter endpoint). The exchange is
then complete and from the client point of view it was processed. As such the
<a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a> have
handled the <a shape="rect" href="exchange.html">Exchange</a>.</p><p>For
instance configuring the dead le
tter channel as:</p><p><strong>Using the <a shape="rect"
href="fluent-builders.html">Fluent Builders</a></strong></p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
@@ -250,7 +250,7 @@ public class MyRedeliverProcessor implem
}
}
]]></script>
-</div></div><p></p><h4 id="DeadLetterChannel-UsingThisPattern">Using This
Pattern</h4>
+</div></div><h3
id="DeadLetterChannel-HowcanIlogwhatcausedtheDeadLetterChanneltobeinvoked?">How
can I log what caused the Dead Letter Channel to be invoked?</h3><p>You often
need to know what went wrong that caused the Dead Letter Channel to be used and
it does not offer logging for this purpose. So the Dead Letter Channel's
endpoint can be set to a endpoint of our own (such
as <code>direct:deadLetterChannel</code>). We write a route to accept this
Exchange and log the Exception, then forward on to where we want the failed
Exchange moved to (which might be a DLQ queue for instance). See also <a
shape="rect" class="external-link"
href="http://stackoverflow.com/questions/13711462/logging-camel-exceptions-and-sending-to-the-dead-letter-channel"
rel="nofollow">http://stackoverflow.com/questions/13711462/logging-camel-exceptions-and-sending-to-the-dead-letter-channel</a></p><p></p><h4
id="DeadLetterChannel-UsingThisPattern">Using This Pattern</h4>
<p>If you would like to use this EIP Pattern then please read the <a
shape="rect" href="getting-started.html">Getting Started</a>, you may also find
the <a shape="rect" href="architecture.html">Architecture</a> useful
particularly the description of <a shape="rect"
href="endpoint.html">Endpoint</a> and <a shape="rect"
href="uris.html">URIs</a>. Then you could try out some of the <a shape="rect"
href="examples.html">Examples</a> first before trying this pattern out.</p><ul
class="alternate"><li><a shape="rect" href="error-handler.html">Error
Handler</a></li><li><a shape="rect" href="exception-clause.html">Exception
Clause</a></li></ul></div>
</td>