camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From astefanu...@apache.org
Subject camel git commit: CAMEL-10685: documentation
Date Fri, 14 Apr 2017 14:26:14 GMT
Repository: camel
Updated Branches:
  refs/heads/master ddd2347d9 -> 6ec8df219


CAMEL-10685: documentation


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6ec8df21
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6ec8df21
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6ec8df21

Branch: refs/heads/master
Commit: 6ec8df21959037351bbf786cc5d1716696ab1829
Parents: ddd2347
Author: Antonin Stefanutti <antonin@stefanutti.fr>
Authored: Fri Apr 14 16:24:49 2017 +0200
Committer: Antonin Stefanutti <antonin@stefanutti.fr>
Committed: Fri Apr 14 16:26:00 2017 +0200

----------------------------------------------------------------------
 components/camel-cdi/src/main/docs/cdi.adoc | 100 +++++++++++++++++++++++
 1 file changed, 100 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/6ec8df21/components/camel-cdi/src/main/docs/cdi.adoc
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/docs/cdi.adoc b/components/camel-cdi/src/main/docs/cdi.adoc
index 572eec3..1a3931e 100644
--- a/components/camel-cdi/src/main/docs/cdi.adoc
+++ b/components/camel-cdi/src/main/docs/cdi.adoc
@@ -855,6 +855,106 @@ configuration, e.g.:
 <camelContext/>
 ----
 
+
+### Transaction support
+
+*Available as of Camel 2.19*
+
+Camel CDI provides support for Camel transactional client using JTA.
+
+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:
+
+[source,xml]
+----
+<dependency>
+    <groupId>javax.transaction</groupId>
+    <artifactId>javax.transaction-api</artifactId>
+    <scope>runtime</scope>
+</dependency>
+----
+
+You'll have to have your application deployed in a JTA capable container or provide a standalone
JTA implementation.
+
+[CAUTION]
+====
+Note that, for the time being, the transaction manager is looked up as JNDI resource with
the `java:/TransactionManager` key.
+
+More flexible strategies will be added in the future to support a wider range of deployment
scenarios.
+====
+
+#### Transaction policies
+
+Camel CDI provides implementation for the typically supported Camel `TransactedPolicy` as
CDI beans. It is possible to have these policies looked up by name using the transacted EIP,
e.g.:
+
+[source,java]
+----
+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");
+    }
+}
+----
+
+This would be equivalent to:
+
+[source,java]
+----
+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");
+    }
+}
+----
+
+The list of supported transaction policy names is:
+
+- `PROPAGATION_NEVER`,
+- `PROPAGATION_NOT_SUPPORTED`,
+- `PROPAGATION_SUPPORTS`,
+- `PROPAGATION_REQUIRED`,
+- `PROPAGATION_REQUIRES_NEW`,
+- `PROPAGATION_NESTED`,
+- `PROPAGATION_MANDATORY`.
+
+#### Transactional error handler
+
+Camel CDI provides a transactional error handler 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 `CdiRouteBuilder` class that exposes the `transactionErrorHandler`
helper method to enable quick access to the configuration, e.g.:
+
+[source,java]
+----
+class MyRouteBean extends CdiRouteBuilder {
+
+    @Override
+    public void configure() {
+        errorHandler(transactionErrorHandler()
+            .setTransactionPolicy("PROPAGATION_SUPPORTS")
+            .maximumRedeliveries(5)
+            .maximumRedeliveryDelay(5000)
+            .collisionAvoidancePercent(10)
+            .backOffMultiplier(1.5));
+    }
+}
+----
+
+
 ### Auto-configured OSGi integration
 
 *Available as of Camel 2.17*


Mime
View raw message