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 2017/04/14 14:18:45 UTC

svn commit: r1010488 - in /websites/production/camel/content: cache/main.pageCache cdi.html

Author: buildbot
Date: Fri Apr 14 14:18:45 2017
New Revision: 1010488

Log:
Production update by buildbot for camel

Modified:
    websites/production/camel/content/cache/main.pageCache
    websites/production/camel/content/cdi.html

Modified: websites/production/camel/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.

Modified: websites/production/camel/content/cdi.html
==============================================================================
--- websites/production/camel/content/cdi.html (original)
+++ websites/production/camel/content/cdi.html Fri Apr 14 14:18:45 2017
@@ -473,6 +473,53 @@ Processor processor = exchange -> exc
         <process ref="baz"/>
     </route>
 &lt;camelContext/&gt;]]></script>
+</div></div><h3 id="CDI-Transactionsupport">Transaction support</h3><p><strong>Available as of Camel 2.19</strong></p><p>Camel CDI provides support for Camel <a shape="rect" href="transactional-client.html">transactional client</a> using JTA.</p><p>That support is optional hence you need to have JTA in your application classpath, e.g., by explicitly add JTA as a dependency when using Maven:</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;
+    &lt;groupId&gt;javax.transaction&lt;/groupId&gt;
+    &lt;artifactId&gt;javax.transaction-api&lt;/artifactId&gt;
+    &lt;scope&gt;runtime&lt;/scope&gt;
+&lt;/dependency&gt;]]></script>
+</div></div><p>You'll have to have your application deployed in a JTA capable container or provide a standalone JTA implementation.</p><div class="confluence-information-macro confluence-information-macro-note"><span class="aui-icon aui-icon-small aui-iconfont-warning confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>Note that, for the time being, the transaction manager is looked up as JNDI resource with the <code>java:/TransactionManager</code> key. More flexible strategies will be added in the future to support a wider range of deployment scenarios.</p></div></div><h4 id="CDI-Transactionpolicies">Transaction policies</h4><p>Camel CDI provides implementation for the typically supported Camel <code>TransactedPolicy</code> as CDI beans. It is possible to have these policies looked up by name using the <code>transacted</code> EIP, e.g.:</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[class MyRouteBean extends RouteBuilder {
+ 
+	@Override
+    public void configure() {
+        from(&quot;activemq:queue:foo&quot;)
+            .transacted(&quot;PROPAGATION_REQUIRED&quot;)
+            .bean(&quot;transformer&quot;)
+            .to(&quot;jpa:my.application.entity.Bar&quot;)
+            .log(&quot;${body.id} inserted&quot;);
+    }
+}]]></script>
+</div></div><p>This would be equivalent to:</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[class MyRouteBean extends RouteBuilder {
+
+    @Inject
+    @Named(&quot;PROPAGATION_REQUIRED&quot;)
+    Policy required;
+ 
+	@Override
+    public void configure() {
+        from(&quot;activemq:queue:foo&quot;)
+            .policy(required)
+            .bean(&quot;transformer&quot;)
+            .to(&quot;jpa:my.application.entity.Bar&quot;)
+            .log(&quot;${body.id} inserted&quot;);
+    }
+}]]></script>
+</div></div><p>The list of supported transaction policy names is: <code>PROPAGATION_NEVER</code>,&#160;<code>PROPAGATION_NOT_SUPPORTED</code>, <code>PROPAGATION_SUPPORTS</code>,&#160;<code>PROPAGATION_REQUIRED</code>,&#160;<code>PROPAGATION_REQUIRES_NEW</code>, <code>PROPAGATION_NESTED</code>,&#160;<code>PROPAGATION_MANDATORY</code>.</p><h4 id="CDI-Transactionalerrorhandler">Transactional error handler</h4><p>Camel CDI provides a transactional <a shape="rect" href="error-handler.html">error handler</a> that extends the redelivery error handler, forces a rollback whenever an exception occurs and creates a new transaction for each redelivery. Camel CDI provides the <code>CdiRouteBuilder</code> class that exposes the <code>transactionErrorHandler</code> helper method to enable quick access to the configuration, e.g.:</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[class MyRouteBean extends CdiRouteBuilder {
+
+	@Override
+    public void configure() {
+        errorHandler(transactionErrorHandler()
+            .setTransactionPolicy(&quot;PROPAGATION_SUPPORTS&quot;)
+            .maximumRedeliveries(5)
+            .maximumRedeliveryDelay(5000)
+            .collisionAvoidancePercent(10)
+            .backOffMultiplier(1.5));
+    }
+}]]></script>
 </div></div><h3 id="CDI-Auto-configuredOSGiintegration">Auto-configured OSGi integration</h3><p><strong>Available as of Camel 2.17</strong></p><p>The Camel context beans are automatically adapted by Camel CDI so that they are registered as OSGi services and the various resolvers (like&#160;<strong><code>ComponentResolver</code></strong> and&#160;<strong><code>DataFormatResolver</code></strong>) integrate with the OSGi registry. That means that the <a shape="rect" href="karaf.html#Karaf-Karafcommands">Karaf Camel commands</a> can be used to operate the Camel contexts auto-configured by Camel CDI, e.g.:</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[karaf@root()&gt; camel:context-list
  Context        Status              Total #       Failed #     Inflight #   Uptime