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> <camelContext/>]]></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[<dependency> + <groupId>javax.transaction</groupId> + <artifactId>javax.transaction-api</artifactId> + <scope>runtime</scope> +</dependency>]]></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("activemq:queue:foo") + .transacted("PROPAGATION_REQUIRED") + .bean("transformer") + .to("jpa:my.application.entity.Bar") + .log("${body.id} inserted"); + } +}]]></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("PROPAGATION_REQUIRED") + Policy required; +Â + @Override + public void configure() { + from("activemq:queue:foo") + .policy(required) + .bean("transformer") + .to("jpa:my.application.entity.Bar") + .log("${body.id} inserted"); + } +}]]></script> +</div></div><p>The list of supported transaction policy names is: <code>PROPAGATION_NEVER</code>, <code>PROPAGATION_NOT_SUPPORTED</code>, <code>PROPAGATION_SUPPORTS</code>, <code>PROPAGATION_REQUIRED</code>, <code>PROPAGATION_REQUIRES_NEW</code>, <code>PROPAGATION_NESTED</code>, <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("PROPAGATION_SUPPORTS") + .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 <strong><code>ComponentResolver</code></strong> and <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()> camel:context-list Context Status Total # Failed # Inflight # Uptime