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 5c8ad483991f CAMEL-24174: camel-core - Strip JPA EntityManager 
property in parallel multicast, recipientList and wireTap
5c8ad483991f is described below

commit 5c8ad483991f0ca0b32781f0867e1c107fb411d5
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Jul 16 17:08:10 2026 +0200

    CAMEL-24174: camel-core - Strip JPA EntityManager property in parallel 
multicast, recipientList and wireTap
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
    
    CAMEL-24174: camel-core - Strip JPA EntityManager property in parallel 
multicast, recipientList and wireTap
    
    Signed-off-by: Claus Ibsen <[email protected]>
    Co-authored-by: Claude Opus 4.6 <[email protected]>
---
 .../src/main/java/org/apache/camel/processor/MulticastProcessor.java  | 4 ++++
 .../main/java/org/apache/camel/processor/RecipientListProcessor.java  | 4 ++++
 .../src/main/java/org/apache/camel/processor/WireTapProcessor.java    | 2 ++
 3 files changed, 10 insertions(+)

diff --git 
a/core/camel-core-processor/src/main/java/org/apache/camel/processor/MulticastProcessor.java
 
b/core/camel-core-processor/src/main/java/org/apache/camel/processor/MulticastProcessor.java
index 71b2fbf6aa28..5a970717ccca 100644
--- 
a/core/camel-core-processor/src/main/java/org/apache/camel/processor/MulticastProcessor.java
+++ 
b/core/camel-core-processor/src/main/java/org/apache/camel/processor/MulticastProcessor.java
@@ -1020,6 +1020,10 @@ public class MulticastProcessor extends 
BaseProcessorSupport
             // copy exchange, and do not share the unit of work
             Exchange copy = 
processorExchangeFactory.createCorrelatedCopy(exchange, false);
             copy.getExchangeExtension().setTransacted(exchange.isTransacted());
+            if (isParallelProcessing()) {
+                // do not share JPA EntityManager in parallel mode as it is 
not thread-safe (CAMEL-22534)
+                copy.removeProperty(Exchange.JPA_ENTITY_MANAGER);
+            }
             // If we are in a transaction, set TRANSACTION_CONTEXT_DATA 
property for new exchanges to share txData
             // during the transaction.
             if (exchange.isTransacted() && 
copy.getProperty(Exchange.TRANSACTION_CONTEXT_DATA) == null) {
diff --git 
a/core/camel-core-processor/src/main/java/org/apache/camel/processor/RecipientListProcessor.java
 
b/core/camel-core-processor/src/main/java/org/apache/camel/processor/RecipientListProcessor.java
index a67cee877818..b052c03b09e5 100644
--- 
a/core/camel-core-processor/src/main/java/org/apache/camel/processor/RecipientListProcessor.java
+++ 
b/core/camel-core-processor/src/main/java/org/apache/camel/processor/RecipientListProcessor.java
@@ -287,6 +287,10 @@ public class RecipientListProcessor extends 
MulticastProcessor {
         // copy exchange, and do not share the unit of work
         Exchange copy = 
processorExchangeFactory.createCorrelatedCopy(exchange, false);
         copy.getExchangeExtension().setTransacted(exchange.isTransacted());
+        if (isParallelProcessing()) {
+            // do not share JPA EntityManager in parallel mode as it is not 
thread-safe (CAMEL-22534)
+            copy.removeProperty(Exchange.JPA_ENTITY_MANAGER);
+        }
 
         // If we are in a transaction, set TRANSACTION_CONTEXT_DATA property 
for new exchanges to share txData
         // during the transaction.
diff --git 
a/core/camel-core-processor/src/main/java/org/apache/camel/processor/WireTapProcessor.java
 
b/core/camel-core-processor/src/main/java/org/apache/camel/processor/WireTapProcessor.java
index 67a6132fa8a9..a6b10784ec44 100644
--- 
a/core/camel-core-processor/src/main/java/org/apache/camel/processor/WireTapProcessor.java
+++ 
b/core/camel-core-processor/src/main/java/org/apache/camel/processor/WireTapProcessor.java
@@ -264,6 +264,8 @@ public class WireTapProcessor extends BaseProcessorSupport
         Exchange target = 
processorExchangeFactory.createCorrelatedCopy(exchange, false);
         // should not be correlated, but we needed to copy without handover
         target.removeProperty(ExchangePropertyKey.CORRELATION_ID);
+        // do not share JPA EntityManager as wire tap runs asynchronously and 
EM is not thread-safe (CAMEL-22534)
+        target.removeProperty(Exchange.JPA_ENTITY_MANAGER);
         // set MEP to InOnly as this wire tap is a fire and forget
         target.setPattern(ExchangePattern.InOnly);
         // move OUT to IN if needed

Reply via email to