This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch fix/CAMEL-24174 in repository https://gitbox.apache.org/repos/asf/camel.git
commit 1d88eff7752e5714ade87a203ec888642e785e1a Author: Claus Ibsen <[email protected]> AuthorDate: Thu Jul 16 14:31:00 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]> Signed-off-by: Claus Ibsen <[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
