This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch camel-4.0.x in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.0.x by this push: new f340c9e9cb5 CAMEL-19782: camel-jpa - Correct docs about TransactionManager -> TransactionStrategy f340c9e9cb5 is described below commit f340c9e9cb5f722645f3542ec05ee312a3158b8e Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Fri Sep 1 13:18:23 2023 +0200 CAMEL-19782: camel-jpa - Correct docs about TransactionManager -> TransactionStrategy --- components/camel-jpa/src/main/docs/jpa-component.adoc | 19 +++++++++++-------- .../camel/component/jpa/TransactionStrategy.java | 6 ++++++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/components/camel-jpa/src/main/docs/jpa-component.adoc b/components/camel-jpa/src/main/docs/jpa-component.adoc index cbac7331b43..81412c32a4a 100644 --- a/components/camel-jpa/src/main/docs/jpa-component.adoc +++ b/components/camel-jpa/src/main/docs/jpa-component.adoc @@ -136,19 +136,22 @@ you do not need to configure this on the `JpaComponent` as shown above. You only need to do so if there is ambiguity, in which case Camel will log a WARN. -== Configuring TransactionManager +== Configuring TransactionStrategy + +The `TransactionStrategy` is a vendor neutral abstraction that allows `camel-jpa` +to easily plugin and work with Spring `TransactionManager` or Quarkus Transaction API. The `JpaComponent` looks up automatically the -`TransactionManager` from the Registry. If Camel -won't find any `TransactionManager` instance registered, it will also +`TransactionStrategy` from the Registry. If Camel +cannot find any `TransactionStrategy` instance registered, it will also look up for the `TransactionTemplate` and try to -extract `TransactionManager` from it. +extract `TransactionStrategy` from it. If none `TransactionTemplate` is available in the registry, -`JpaEndpoint` will auto create their own instance of -`TransactionManager` which most often is not what you want. +`JpaEndpoint` will auto create a default instance (`org.apache.camel.component.jpa.DefaultTransactionStrategy`) +of `TransactionStrategy` which most often is not what you want. -If more than single instance of the `TransactionManager` is found, Camel +If more than single instance of the `TransactionStrategy` is found, Camel will log a WARN. In such cases you might want to instantiate and explicitly configure a JPA component that references the `myTransactionManager` transaction manager, as follows: @@ -157,7 +160,7 @@ explicitly configure a JPA component that references the ------------------------------------------------------------------- <bean id="jpa" class="org.apache.camel.component.jpa.JpaComponent"> <property name="entityManagerFactory" ref="myEMFactory"/> - <property name="transactionManager" ref="myTransactionManager"/> + <property name="transactionStrategy" ref="myTransactionStrategy"/> </bean> ------------------------------------------------------------------- diff --git a/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/TransactionStrategy.java b/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/TransactionStrategy.java index 3091a1846b0..3a6255ccba5 100644 --- a/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/TransactionStrategy.java +++ b/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/TransactionStrategy.java @@ -20,5 +20,11 @@ package org.apache.camel.component.jpa; * A transaction strategy that is used to run the JPA operations in a transaction. */ public interface TransactionStrategy { + + /** + * Execute the work in transaction. + * + * @param runnable the work to execute. + */ void executeInTransaction(Runnable runnable); }