You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/08/02 10:35:20 UTC

[camel] branch main updated: CAMEL-19225: camel-jpa - remove transactionManager property (#10954)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 4c9a83a783e CAMEL-19225: camel-jpa - remove transactionManager property (#10954)
4c9a83a783e is described below

commit 4c9a83a783e5890ee6d7319320d70d90b1066f61
Author: Zheng Feng <zh...@gmail.com>
AuthorDate: Wed Aug 2 18:35:14 2023 +0800

    CAMEL-19225: camel-jpa - remove transactionManager property (#10954)
---
 .../org/apache/camel/catalog/components/jpa.json   | 13 +++--
 .../component/jpa/JpaComponentConfigurer.java      |  6 ---
 .../org/apache/camel/component/jpa/jpa.json        | 13 +++--
 .../component/jpa/DefaultTransactionStrategy.java  | 61 ++++++++++++++++++---
 .../apache/camel/component/jpa/JpaComponent.java   | 62 ++--------------------
 .../apache/camel/component/jpa/JpaEndpoint.java    | 36 +------------
 .../component/jpa/AbstractJpaMethodSupport.java    |  4 +-
 .../camel/component/jpa/JpaComponentTest.java      | 18 ++++---
 .../camel/component/jpa/JpaEndpointTest.java       | 22 +++++---
 .../org/apache/camel/component/jpa/JpaTest.java    |  4 +-
 .../jpa/JpaWithNamedQueryAndParametersTest.java    |  4 +-
 .../camel/component/jpa/JpaWithNamedQueryTest.java |  4 +-
 .../apache/camel/processor/jpa/JpaRouteTest.java   |  2 +-
 .../apache/camel/processor/jpa/JpaWireTapTest.java |  2 +-
 .../component/dsl/JpaComponentBuilderFactory.java  | 18 -------
 15 files changed, 110 insertions(+), 159 deletions(-)

diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jpa.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jpa.json
index ef71661c3ad..88306f13a15 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jpa.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jpa.json
@@ -26,13 +26,12 @@
     "entityManagerFactory": { "index": 1, "kind": "property", "displayName": "Entity Manager Factory", "group": "common", "label": "", "required": false, "type": "object", "javaType": "jakarta.persistence.EntityManagerFactory", "deprecated": false, "autowired": false, "secret": false, "description": "To use the EntityManagerFactory. This is strongly recommended to configure." },
     "joinTransaction": { "index": 2, "kind": "property", "displayName": "Join Transaction", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "The camel-jpa component will join transaction by default. You can use this option to turn this off, for example if you use LOCAL_RESOURCE and join transaction doesn't work with your JPA provider. This option can [...]
     "sharedEntityManager": { "index": 3, "kind": "property", "displayName": "Shared Entity Manager", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to use Spring's SharedEntityManager for the consumer\/producer. Note in most cases joinTransaction should be set to false as this is not an EXTENDED EntityManager." },
-    "transactionManager": { "index": 4, "kind": "property", "displayName": "Transaction Manager", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.springframework.transaction.PlatformTransactionManager", "deprecated": true, "autowired": false, "secret": false, "description": "To use the PlatformTransactionManager for managing transactions." },
-    "transactionStrategy": { "index": 5, "kind": "property", "displayName": "Transaction Strategy", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.jpa.TransactionStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "To use the TransactionStrategy for running the operations in a transaction." },
-    "bridgeErrorHandler": { "index": 6, "kind": "property", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be proce [...]
-    "lazyStartProducer": { "index": 7, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail [...]
-    "autowiredEnabled": { "index": 8, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...]
-    "healthCheckConsumerEnabled": { "index": 9, "kind": "property", "displayName": "Health Check Consumer Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all consumer based health checks from this component" },
-    "healthCheckProducerEnabled": { "index": 10, "kind": "property", "displayName": "Health Check Producer Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all producer based health checks from this component. Notice: Camel has by default disabled all producer based health-checks. You can turn on produce [...]
+    "transactionStrategy": { "index": 4, "kind": "property", "displayName": "Transaction Strategy", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.jpa.TransactionStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "To use the TransactionStrategy for running the operations in a transaction." },
+    "bridgeErrorHandler": { "index": 5, "kind": "property", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be proce [...]
+    "lazyStartProducer": { "index": 6, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail [...]
+    "autowiredEnabled": { "index": 7, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...]
+    "healthCheckConsumerEnabled": { "index": 8, "kind": "property", "displayName": "Health Check Consumer Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all consumer based health checks from this component" },
+    "healthCheckProducerEnabled": { "index": 9, "kind": "property", "displayName": "Health Check Producer Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all producer based health checks from this component. Notice: Camel has by default disabled all producer based health-checks. You can turn on producer [...]
   },
   "headers": {
     "CamelEntityManager": { "index": 0, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "jakarta.persistence.EntityManager", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The JPA EntityManager object.", "constantName": "org.apache.camel.component.jpa.JpaConstants#ENTITY_MANAGER" },
diff --git a/components/camel-jpa/src/generated/java/org/apache/camel/component/jpa/JpaComponentConfigurer.java b/components/camel-jpa/src/generated/java/org/apache/camel/component/jpa/JpaComponentConfigurer.java
index 52fb8e251ba..03f39e933b4 100644
--- a/components/camel-jpa/src/generated/java/org/apache/camel/component/jpa/JpaComponentConfigurer.java
+++ b/components/camel-jpa/src/generated/java/org/apache/camel/component/jpa/JpaComponentConfigurer.java
@@ -38,8 +38,6 @@ public class JpaComponentConfigurer extends PropertyConfigurerSupport implements
         case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true;
         case "sharedentitymanager":
         case "sharedEntityManager": target.setSharedEntityManager(property(camelContext, boolean.class, value)); return true;
-        case "transactionmanager":
-        case "transactionManager": target.setTransactionManager(property(camelContext, org.springframework.transaction.PlatformTransactionManager.class, value)); return true;
         case "transactionstrategy":
         case "transactionStrategy": target.setTransactionStrategy(property(camelContext, org.apache.camel.component.jpa.TransactionStrategy.class, value)); return true;
         default: return false;
@@ -66,8 +64,6 @@ public class JpaComponentConfigurer extends PropertyConfigurerSupport implements
         case "lazyStartProducer": return boolean.class;
         case "sharedentitymanager":
         case "sharedEntityManager": return boolean.class;
-        case "transactionmanager":
-        case "transactionManager": return org.springframework.transaction.PlatformTransactionManager.class;
         case "transactionstrategy":
         case "transactionStrategy": return org.apache.camel.component.jpa.TransactionStrategy.class;
         default: return null;
@@ -95,8 +91,6 @@ public class JpaComponentConfigurer extends PropertyConfigurerSupport implements
         case "lazyStartProducer": return target.isLazyStartProducer();
         case "sharedentitymanager":
         case "sharedEntityManager": return target.isSharedEntityManager();
-        case "transactionmanager":
-        case "transactionManager": return target.getTransactionManager();
         case "transactionstrategy":
         case "transactionStrategy": return target.getTransactionStrategy();
         default: return null;
diff --git a/components/camel-jpa/src/generated/resources/org/apache/camel/component/jpa/jpa.json b/components/camel-jpa/src/generated/resources/org/apache/camel/component/jpa/jpa.json
index ef71661c3ad..88306f13a15 100644
--- a/components/camel-jpa/src/generated/resources/org/apache/camel/component/jpa/jpa.json
+++ b/components/camel-jpa/src/generated/resources/org/apache/camel/component/jpa/jpa.json
@@ -26,13 +26,12 @@
     "entityManagerFactory": { "index": 1, "kind": "property", "displayName": "Entity Manager Factory", "group": "common", "label": "", "required": false, "type": "object", "javaType": "jakarta.persistence.EntityManagerFactory", "deprecated": false, "autowired": false, "secret": false, "description": "To use the EntityManagerFactory. This is strongly recommended to configure." },
     "joinTransaction": { "index": 2, "kind": "property", "displayName": "Join Transaction", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "The camel-jpa component will join transaction by default. You can use this option to turn this off, for example if you use LOCAL_RESOURCE and join transaction doesn't work with your JPA provider. This option can [...]
     "sharedEntityManager": { "index": 3, "kind": "property", "displayName": "Shared Entity Manager", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to use Spring's SharedEntityManager for the consumer\/producer. Note in most cases joinTransaction should be set to false as this is not an EXTENDED EntityManager." },
-    "transactionManager": { "index": 4, "kind": "property", "displayName": "Transaction Manager", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.springframework.transaction.PlatformTransactionManager", "deprecated": true, "autowired": false, "secret": false, "description": "To use the PlatformTransactionManager for managing transactions." },
-    "transactionStrategy": { "index": 5, "kind": "property", "displayName": "Transaction Strategy", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.jpa.TransactionStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "To use the TransactionStrategy for running the operations in a transaction." },
-    "bridgeErrorHandler": { "index": 6, "kind": "property", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be proce [...]
-    "lazyStartProducer": { "index": 7, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail [...]
-    "autowiredEnabled": { "index": 8, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...]
-    "healthCheckConsumerEnabled": { "index": 9, "kind": "property", "displayName": "Health Check Consumer Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all consumer based health checks from this component" },
-    "healthCheckProducerEnabled": { "index": 10, "kind": "property", "displayName": "Health Check Producer Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all producer based health checks from this component. Notice: Camel has by default disabled all producer based health-checks. You can turn on produce [...]
+    "transactionStrategy": { "index": 4, "kind": "property", "displayName": "Transaction Strategy", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.jpa.TransactionStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "To use the TransactionStrategy for running the operations in a transaction." },
+    "bridgeErrorHandler": { "index": 5, "kind": "property", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be proce [...]
+    "lazyStartProducer": { "index": 6, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail [...]
+    "autowiredEnabled": { "index": 7, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...]
+    "healthCheckConsumerEnabled": { "index": 8, "kind": "property", "displayName": "Health Check Consumer Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all consumer based health checks from this component" },
+    "healthCheckProducerEnabled": { "index": 9, "kind": "property", "displayName": "Health Check Producer Enabled", "group": "health", "label": "health", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Used for enabling or disabling all producer based health checks from this component. Notice: Camel has by default disabled all producer based health-checks. You can turn on producer [...]
   },
   "headers": {
     "CamelEntityManager": { "index": 0, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "jakarta.persistence.EntityManager", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The JPA EntityManager object.", "constantName": "org.apache.camel.component.jpa.JpaConstants#ENTITY_MANAGER" },
diff --git a/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/DefaultTransactionStrategy.java b/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/DefaultTransactionStrategy.java
index 0602ddd839f..fb75d197c60 100644
--- a/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/DefaultTransactionStrategy.java
+++ b/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/DefaultTransactionStrategy.java
@@ -16,23 +16,27 @@
  */
 package org.apache.camel.component.jpa;
 
+import java.util.Map;
+
 import jakarta.persistence.EntityManagerFactory;
 
+import org.apache.camel.CamelContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.orm.jpa.JpaTransactionManager;
 import org.springframework.transaction.PlatformTransactionManager;
 import org.springframework.transaction.TransactionDefinition;
 import org.springframework.transaction.support.TransactionTemplate;
 
 public class DefaultTransactionStrategy implements TransactionStrategy {
-    private final TransactionTemplate transactionTemplate;
-    private final PlatformTransactionManager transactionManager;
+    private static final Logger LOG = LoggerFactory.getLogger(DefaultTransactionStrategy.class);
+    private TransactionTemplate transactionTemplate;
+    private PlatformTransactionManager transactionManager;
 
-    public DefaultTransactionStrategy(PlatformTransactionManager transactionManager,
-                                      EntityManagerFactory entityManagerFactory) {
-        if (transactionManager == null) {
+    public DefaultTransactionStrategy(CamelContext camelContext, EntityManagerFactory entityManagerFactory) {
+        initTransactionManager(camelContext);
+        if (transactionManager == null && entityManagerFactory != null) {
             this.transactionManager = createTransactionManager(entityManagerFactory);
-        } else {
-            this.transactionManager = transactionManager;
         }
         this.transactionTemplate = createTransactionTemplate();
     }
@@ -49,6 +53,49 @@ public class DefaultTransactionStrategy implements TransactionStrategy {
         return transactionManager;
     }
 
+    public void setTransactionManager(PlatformTransactionManager transactionManager) {
+        this.transactionManager = transactionManager;
+        this.transactionTemplate = createTransactionTemplate();
+    }
+
+    public TransactionTemplate getTransactionTemplate() {
+        return transactionTemplate;
+    }
+
+    private void initTransactionManager(CamelContext camelContext) {
+        // lookup transaction manager and use it if only one provided
+        if (transactionManager == null && camelContext != null) {
+            Map<String, PlatformTransactionManager> map
+                    = camelContext.getRegistry().findByTypeWithName(PlatformTransactionManager.class);
+            if (map != null) {
+                if (map.size() == 1) {
+                    transactionManager = map.values().iterator().next();
+                    LOG.info("Using TransactionManager found in registry with id [{}] {}",
+                            map.keySet().iterator().next(), transactionManager);
+                } else {
+                    LOG.debug("Could not find a single TransactionManager in registry as there was {} instances.", map.size());
+                }
+            }
+        } else {
+            LOG.info("Using TransactionManager configured on this component: {}", transactionManager);
+        }
+
+        // transaction manager could also be hidden in a template
+        if (transactionManager == null && camelContext != null) {
+            Map<String, TransactionTemplate> map
+                    = camelContext.getRegistry().findByTypeWithName(TransactionTemplate.class);
+            if (map != null) {
+                if (map.size() == 1) {
+                    transactionManager = map.values().iterator().next().getTransactionManager();
+                    LOG.info("Using TransactionManager found in registry with id [{}] {}",
+                            map.keySet().iterator().next(), transactionManager);
+                } else {
+                    LOG.debug("Could not find a single TransactionTemplate in registry as there was {} instances.", map.size());
+                }
+            }
+        }
+    }
+
     protected PlatformTransactionManager createTransactionManager(EntityManagerFactory entityManagerFactory) {
         JpaTransactionManager tm = new JpaTransactionManager(entityManagerFactory);
         tm.afterPropertiesSet();
diff --git a/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaComponent.java b/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaComponent.java
index 8d93eda857e..b409f57e01c 100644
--- a/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaComponent.java
+++ b/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaComponent.java
@@ -30,8 +30,6 @@ import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.PropertiesHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.transaction.PlatformTransactionManager;
-import org.springframework.transaction.support.TransactionTemplate;
 
 /**
  * A JPA Component
@@ -45,9 +43,6 @@ public class JpaComponent extends HealthCheckComponent {
 
     @Metadata
     private EntityManagerFactory entityManagerFactory;
-    @Deprecated
-    @Metadata
-    private PlatformTransactionManager transactionManager;
     @Metadata
     private TransactionStrategy transactionStrategy;
     @Metadata(defaultValue = "true")
@@ -74,21 +69,6 @@ public class JpaComponent extends HealthCheckComponent {
         this.entityManagerFactory = entityManagerFactory;
     }
 
-    @Deprecated
-    public PlatformTransactionManager getTransactionManager() {
-        return transactionManager;
-    }
-
-    /**
-     * To use the {@link PlatformTransactionManager} for managing transactions.
-     *
-     * @deprecated - use {@link #setTransactionStrategy(TransactionStrategy)} instead
-     */
-    @Deprecated
-    public void setTransactionManager(PlatformTransactionManager transactionManager) {
-        this.transactionManager = transactionManager;
-    }
-
     public TransactionStrategy getTransactionStrategy() {
         return transactionStrategy;
     }
@@ -201,40 +181,6 @@ public class JpaComponent extends HealthCheckComponent {
         }
     }
 
-    private void initTransactionManager() {
-        // lookup transaction manager and use it if only one provided
-        if (transactionManager == null) {
-            Map<String, PlatformTransactionManager> map
-                    = getCamelContext().getRegistry().findByTypeWithName(PlatformTransactionManager.class);
-            if (map != null) {
-                if (map.size() == 1) {
-                    transactionManager = map.values().iterator().next();
-                    LOG.info("Using TransactionManager found in registry with id [{}] {}",
-                            map.keySet().iterator().next(), transactionManager);
-                } else {
-                    LOG.debug("Could not find a single TransactionManager in registry as there was {} instances.", map.size());
-                }
-            }
-        } else {
-            LOG.info("Using TransactionManager configured on this component: {}", transactionManager);
-        }
-
-        // transaction manager could also be hidden in a template
-        if (transactionManager == null) {
-            Map<String, TransactionTemplate> map
-                    = getCamelContext().getRegistry().findByTypeWithName(TransactionTemplate.class);
-            if (map != null) {
-                if (map.size() == 1) {
-                    transactionManager = map.values().iterator().next().getTransactionManager();
-                    LOG.info("Using TransactionManager found in registry with id [{}] {}",
-                            map.keySet().iterator().next(), transactionManager);
-                } else {
-                    LOG.debug("Could not find a single TransactionTemplate in registry as there was {} instances.", map.size());
-                }
-            }
-        }
-    }
-
     @Override
     protected void doInit() throws Exception {
         super.doInit();
@@ -245,17 +191,15 @@ public class JpaComponent extends HealthCheckComponent {
             return;
         }
 
-        initTransactionManager();
+        if (transactionStrategy == null && getEntityManagerFactory() != null) {
+            transactionStrategy = new DefaultTransactionStrategy(getCamelContext(), getEntityManagerFactory());
+        }
 
         // warn about missing configuration
         if (entityManagerFactory == null) {
             LOG.warn(
                     "No EntityManagerFactory has been configured on this JpaComponent. Each JpaEndpoint will auto create their own EntityManagerFactory.");
         }
-        if (transactionManager == null) {
-            LOG.warn(
-                    "No TransactionManager has been configured on this JpaComponent. Each JpaEndpoint will auto create their own JpaTransactionManager.");
-        }
     }
 
     @Override
diff --git a/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaEndpoint.java b/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaEndpoint.java
index 5f5ee80ea77..8aac9540ca5 100644
--- a/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaEndpoint.java
+++ b/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaEndpoint.java
@@ -42,9 +42,6 @@ import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.PropertiesHelper;
 import org.springframework.orm.jpa.LocalEntityManagerFactoryBean;
 import org.springframework.orm.jpa.SharedEntityManagerCreator;
-import org.springframework.transaction.PlatformTransactionManager;
-import org.springframework.transaction.TransactionDefinition;
-import org.springframework.transaction.support.TransactionTemplate;
 
 /**
  * Store and retrieve Java objects from databases using Java Persistence API (JPA).
@@ -54,7 +51,6 @@ import org.springframework.transaction.support.TransactionTemplate;
 public class JpaEndpoint extends ScheduledPollEndpoint {
 
     private EntityManagerFactory entityManagerFactory;
-    private PlatformTransactionManager transactionManager;
     private TransactionStrategy transactionStrategy;
     private Expression producerExpression;
 
@@ -251,26 +247,6 @@ public class JpaEndpoint extends ScheduledPollEndpoint {
         this.entityManagerFactory = entityManagerFactory;
     }
 
-    public PlatformTransactionManager getTransactionManager() {
-        if (transactionManager == null) {
-            if (transactionStrategy == null) {
-                DefaultTransactionStrategy defaultTransactionStrategy = createTransactionStrategy();
-                transactionStrategy = defaultTransactionStrategy;
-                transactionManager = defaultTransactionStrategy.getTransactionManager();
-            } else if (transactionStrategy instanceof DefaultTransactionStrategy) {
-                transactionManager = ((DefaultTransactionStrategy) transactionStrategy).getTransactionManager();
-            }
-        }
-        return transactionManager;
-    }
-
-    /**
-     * To use the {@link PlatformTransactionManager} for managing transactions.
-     */
-    public void setTransactionManager(PlatformTransactionManager transactionManager) {
-        this.transactionManager = transactionManager;
-    }
-
     public TransactionStrategy getTransactionStrategy() {
         if (transactionStrategy == null) {
             transactionStrategy = createTransactionStrategy();
@@ -613,15 +589,8 @@ public class JpaEndpoint extends ScheduledPollEndpoint {
         }
     }
 
-    protected TransactionTemplate createTransactionTemplate() {
-        TransactionTemplate transactionTemplate = new TransactionTemplate(getTransactionManager());
-        transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
-        transactionTemplate.afterPropertiesSet();
-        return transactionTemplate;
-    }
-
     protected DefaultTransactionStrategy createTransactionStrategy() {
-        return new DefaultTransactionStrategy(transactionManager, getEntityManagerFactory());
+        return new DefaultTransactionStrategy(getCamelContext(), getEntityManagerFactory());
     }
 
     protected Expression createProducerExpression() {
@@ -656,8 +625,5 @@ public class JpaEndpoint extends ScheduledPollEndpoint {
         if (transactionStrategy == null && getComponent() != null) {
             transactionStrategy = getComponent().getTransactionStrategy();
         }
-        if (transactionManager == null && getComponent() != null) {
-            transactionManager = getComponent().getTransactionManager();
-        }
     }
 }
diff --git a/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/AbstractJpaMethodSupport.java b/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/AbstractJpaMethodSupport.java
index dbd70b3b4dd..0eaa0bd79be 100644
--- a/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/AbstractJpaMethodSupport.java
+++ b/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/AbstractJpaMethodSupport.java
@@ -49,7 +49,9 @@ public class AbstractJpaMethodSupport extends CamelTestSupport {
     protected void setUp(String endpointUri) throws Exception {
         endpoint = context.getEndpoint(endpointUri, JpaEndpoint.class);
 
-        transactionTemplate = endpoint.createTransactionTemplate();
+        if (endpoint.getTransactionStrategy() instanceof DefaultTransactionStrategy strategy) {
+            transactionTemplate = strategy.getTransactionTemplate();
+        }
         entityManager = endpoint.getEntityManagerFactory().createEntityManager();
 
         transactionTemplate.execute(new TransactionCallback<Object>() {
diff --git a/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaComponentTest.java b/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaComponentTest.java
index f397e556f6b..c39b86e5008 100644
--- a/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaComponentTest.java
+++ b/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaComponentTest.java
@@ -37,7 +37,7 @@ public class JpaComponentTest extends CamelTestSupport {
         try (JpaComponent comp = new JpaComponent()) {
             comp.setCamelContext(context);
             assertNull(comp.getEntityManagerFactory());
-            assertNull(comp.getTransactionManager());
+            assertNull(comp.getTransactionStrategy());
 
             JpaEndpoint jpa
                     = (JpaEndpoint) comp
@@ -53,7 +53,7 @@ public class JpaComponentTest extends CamelTestSupport {
         try (JpaComponent comp = new JpaComponent()) {
             comp.setCamelContext(context);
             assertNull(comp.getEntityManagerFactory());
-            assertNull(comp.getTransactionManager());
+            assertNull(comp.getTransactionStrategy());
 
             JpaEndpoint jpa = (JpaEndpoint) comp.createEndpoint("jpa://" + SendEmail.class.getName());
             assertNotNull(jpa);
@@ -66,17 +66,21 @@ public class JpaComponentTest extends CamelTestSupport {
         try (JpaComponent comp = new JpaComponent()) {
             comp.setCamelContext(context);
             assertNull(comp.getEntityManagerFactory());
-            assertNull(comp.getTransactionManager());
+            assertNull(comp.getTransactionStrategy());
 
             EntityManagerFactory fac = Persistence.createEntityManagerFactory("camel");
             JpaTransactionManager tm = new JpaTransactionManager(fac);
             tm.afterPropertiesSet();
 
             comp.setEntityManagerFactory(fac);
-            comp.setTransactionManager(tm);
+            if (comp.getTransactionStrategy() instanceof DefaultTransactionStrategy strategy) {
+                strategy.setTransactionManager(tm);
+            }
 
             assertSame(fac, comp.getEntityManagerFactory());
-            assertSame(tm, comp.getTransactionManager());
+            if (comp.getTransactionStrategy() instanceof DefaultTransactionStrategy strategy) {
+                assertSame(tm, strategy.getTransactionManager());
+            }
 
             JpaEndpoint jpa = (JpaEndpoint) comp.createEndpoint("jpa://" + SendEmail.class.getName());
             assertNotNull(jpa);
@@ -89,7 +93,7 @@ public class JpaComponentTest extends CamelTestSupport {
         try (JpaComponent comp = new JpaComponent()) {
             comp.setCamelContext(context);
             assertNull(comp.getEntityManagerFactory());
-            assertNull(comp.getTransactionManager());
+            assertNull(comp.getTransactionStrategy());
 
             JpaEndpoint jpa = (JpaEndpoint) comp.createEndpoint(
                     "jpa://" + SendEmail.class.getName() + "?persistenceUnit=journalPersistenceUnit&usePersist=true");
@@ -103,7 +107,7 @@ public class JpaComponentTest extends CamelTestSupport {
         try (JpaComponent comp = new JpaComponent()) {
             comp.setCamelContext(context);
             assertNull(comp.getEntityManagerFactory());
-            assertNull(comp.getTransactionManager());
+            assertNull(comp.getTransactionStrategy());
 
             JpaEndpoint jpa = (JpaEndpoint) comp.createEndpoint("jpa:?persistenceUnit=journalPersistenceUnit&usePersist=true");
             assertNotNull(jpa);
diff --git a/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaEndpointTest.java b/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaEndpointTest.java
index 7b996e35f25..b91c9374a5f 100644
--- a/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaEndpointTest.java
+++ b/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaEndpointTest.java
@@ -38,7 +38,7 @@ public class JpaEndpointTest extends CamelTestSupport {
         jpa.setEntityType(SendEmail.class);
 
         assertNotNull(jpa.getEntityManagerFactory());
-        assertNotNull(jpa.getTransactionManager());
+        assertNotNull(jpa.getTransactionStrategy());
 
         assertEquals("jpa://org.apache.camel.examples.SendEmail", jpa.getEndpointUri());
         assertEquals("camel", jpa.getPersistenceUnit());
@@ -57,7 +57,7 @@ public class JpaEndpointTest extends CamelTestSupport {
         jpa.setEntityType(SendEmail.class);
 
         assertNotNull(jpa.getEntityManagerFactory());
-        assertNotNull(jpa.getTransactionManager());
+        assertNotNull(jpa.getTransactionStrategy());
 
         assertEquals("jpa://org.apache.camel.examples.SendEmail", jpa.getEndpointUri());
         assertEquals("camel", jpa.getPersistenceUnit());
@@ -79,7 +79,7 @@ public class JpaEndpointTest extends CamelTestSupport {
         jpa.setEntityType(SendEmail.class);
 
         assertSame(fac, jpa.getEntityManagerFactory());
-        assertNotNull(jpa.getTransactionManager());
+        assertNotNull(jpa.getTransactionStrategy());
 
         assertEquals("jpa://org.apache.camel.examples.SendEmail", jpa.getEndpointUri());
         assertEquals("camel", jpa.getPersistenceUnit());
@@ -100,11 +100,15 @@ public class JpaEndpointTest extends CamelTestSupport {
 
         JpaEndpoint jpa = new JpaEndpoint("jpa://org.apache.camel.examples.SendEmail", null);
         jpa.setEntityManagerFactory(fac);
-        jpa.setTransactionManager(tm);
+        if (jpa.getTransactionStrategy() instanceof DefaultTransactionStrategy strategy) {
+            strategy.setTransactionManager(tm);
+        }
         jpa.setEntityType(SendEmail.class);
 
         assertSame(fac, jpa.getEntityManagerFactory());
-        assertSame(tm, jpa.getTransactionManager());
+        if (jpa.getTransactionStrategy() instanceof DefaultTransactionStrategy strategy) {
+            assertSame(tm, strategy.getTransactionManager());
+        }
 
         assertEquals("jpa://org.apache.camel.examples.SendEmail", jpa.getEndpointUri());
         assertEquals("camel", jpa.getPersistenceUnit());
@@ -121,10 +125,14 @@ public class JpaEndpointTest extends CamelTestSupport {
         jpa.setEntityType(SendEmail.class);
 
         jpa.setEntityManagerFactory(fac);
-        jpa.setTransactionManager(tm);
+        if (jpa.getTransactionStrategy() instanceof DefaultTransactionStrategy strategy) {
+            strategy.setTransactionManager(tm);
+        }
 
         assertSame(fac, jpa.getEntityManagerFactory());
-        assertSame(tm, jpa.getTransactionManager());
+        if (jpa.getTransactionStrategy() instanceof DefaultTransactionStrategy strategy) {
+            assertSame(tm, strategy.getTransactionManager());
+        }
 
         assertEquals("jpa://org.apache.camel.examples.SendEmail", jpa.getEndpointUri());
         assertEquals("camel", jpa.getPersistenceUnit());
diff --git a/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaTest.java b/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaTest.java
index dfa8bc1442f..3ee6f6d03f7 100644
--- a/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaTest.java
+++ b/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaTest.java
@@ -135,7 +135,9 @@ public class JpaTest {
 
         listEndpoint = camelContext.getEndpoint(getEndpointUri() + "&entityType=java.util.List", JpaEndpoint.class);
 
-        transactionTemplate = endpoint.createTransactionTemplate();
+        if (endpoint.getTransactionStrategy() instanceof DefaultTransactionStrategy strategy) {
+            transactionTemplate = strategy.getTransactionTemplate();
+        }
         entityManager = endpoint.getEntityManagerFactory().createEntityManager();
 
         transactionTemplate.execute(new TransactionCallback<Object>() {
diff --git a/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaWithNamedQueryAndParametersTest.java b/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaWithNamedQueryAndParametersTest.java
index c6c91812bb5..aad3646e99e 100644
--- a/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaWithNamedQueryAndParametersTest.java
+++ b/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaWithNamedQueryAndParametersTest.java
@@ -142,7 +142,9 @@ public class JpaWithNamedQueryAndParametersTest {
         assertTrue(value instanceof JpaEndpoint, "Should be a JPA endpoint but was: " + value);
         endpoint = (JpaEndpoint) value;
 
-        transactionTemplate = endpoint.createTransactionTemplate();
+        if (endpoint.getTransactionStrategy() instanceof DefaultTransactionStrategy strategy) {
+            transactionTemplate = strategy.getTransactionTemplate();
+        }
         entityManager = endpoint.getEntityManagerFactory().createEntityManager();
     }
 
diff --git a/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaWithNamedQueryTest.java b/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaWithNamedQueryTest.java
index 5aaf2bc4c8f..67e21b1e1e1 100644
--- a/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaWithNamedQueryTest.java
+++ b/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaWithNamedQueryTest.java
@@ -173,7 +173,9 @@ public class JpaWithNamedQueryTest {
         assertTrue(value instanceof JpaEndpoint, "Should be a JPA endpoint but was: " + value);
         endpoint = (JpaEndpoint) value;
 
-        transactionTemplate = endpoint.createTransactionTemplate();
+        if (endpoint.getTransactionStrategy() instanceof DefaultTransactionStrategy strategy) {
+            transactionTemplate = strategy.getTransactionTemplate();
+        }
         entityManager = endpoint.getEntityManagerFactory().createEntityManager();
     }
 
diff --git a/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaRouteTest.java b/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaRouteTest.java
index 8573afdc053..a0237c8032f 100644
--- a/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaRouteTest.java
+++ b/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaRouteTest.java
@@ -35,7 +35,7 @@ public class JpaRouteTest extends AbstractJpaTest {
         // should auto setup transaction manager and entity factory
         JpaComponent jpa = context.getComponent("jpa", JpaComponent.class);
         assertNotNull(jpa.getEntityManagerFactory(), "Should have been auto assigned");
-        assertNotNull(jpa.getTransactionManager(), "Should have been auto assigned");
+        assertNotNull(jpa.getTransactionStrategy(), "Should have been auto assigned");
 
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);
diff --git a/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaWireTapTest.java b/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaWireTapTest.java
index 1703f6882a1..c402115612e 100644
--- a/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaWireTapTest.java
+++ b/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaWireTapTest.java
@@ -32,7 +32,7 @@ public class JpaWireTapTest extends AbstractJpaTest {
         // should auto setup transaction manager and entity factory
         JpaComponent jpa = context.getComponent("jpa", JpaComponent.class);
         assertNotNull(jpa.getEntityManagerFactory(), "Should have been auto assigned");
-        assertNotNull(jpa.getTransactionManager(), "Should have been auto assigned");
+        assertNotNull(jpa.getTransactionStrategy(), "Should have been auto assigned");
 
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(2);
diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/JpaComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/JpaComponentBuilderFactory.java
index 75c80f1b300..d32b7a7c236 100644
--- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/JpaComponentBuilderFactory.java
+++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/JpaComponentBuilderFactory.java
@@ -123,23 +123,6 @@ public interface JpaComponentBuilderFactory {
             doSetProperty("sharedEntityManager", sharedEntityManager);
             return this;
         }
-        /**
-         * To use the PlatformTransactionManager for managing transactions.
-         * 
-         * The option is a:
-         * &lt;code&gt;org.springframework.transaction.PlatformTransactionManager&lt;/code&gt; type.
-         * 
-         * Group: common
-         * 
-         * @param transactionManager the value to set
-         * @return the dsl builder
-         */
-        @Deprecated
-        default JpaComponentBuilder transactionManager(
-                org.springframework.transaction.PlatformTransactionManager transactionManager) {
-            doSetProperty("transactionManager", transactionManager);
-            return this;
-        }
         /**
          * To use the TransactionStrategy for running the operations in a
          * transaction.
@@ -279,7 +262,6 @@ public interface JpaComponentBuilderFactory {
             case "entityManagerFactory": ((JpaComponent) component).setEntityManagerFactory((jakarta.persistence.EntityManagerFactory) value); return true;
             case "joinTransaction": ((JpaComponent) component).setJoinTransaction((boolean) value); return true;
             case "sharedEntityManager": ((JpaComponent) component).setSharedEntityManager((boolean) value); return true;
-            case "transactionManager": ((JpaComponent) component).setTransactionManager((org.springframework.transaction.PlatformTransactionManager) value); return true;
             case "transactionStrategy": ((JpaComponent) component).setTransactionStrategy((org.apache.camel.component.jpa.TransactionStrategy) value); return true;
             case "bridgeErrorHandler": ((JpaComponent) component).setBridgeErrorHandler((boolean) value); return true;
             case "lazyStartProducer": ((JpaComponent) component).setLazyStartProducer((boolean) value); return true;