allthingssecurity commented on code in PR #27983: URL: https://github.com/apache/camel/pull/27983#discussion_r4301872712
########## docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc: ########## @@ -452,6 +452,13 @@ again. With `transacted=true` the SQL and MyBatis consumers break out of the bat `markRollbackOnlyLast()` reaches the consumer only when no `transacted()` EIP has consumed the flag, so the consumer's own transaction is the last one. +=== camel-jta - an exchange marked rollback only last rolls back its transaction + +In a `transacted()` route that uses a JTA transaction manager, `markRollbackOnlyLast()` now rolls back the +transaction of that `transacted()` block, as it already did with the camel-spring transaction error handler. Before, +the transaction was committed, and the marker was then cleared, so nothing showed that the rollback was skipped. +The marker is still cleared afterwards, so an outer `transacted()` block does not see it. Review Comment: Thanks, added in 6c895dfbfd9d. I checked it against the Camel Quarkus policies first: `RequiredJtaTransactionPolicy` joins an active transaction and `MandatoryJtaTransactionPolicy` always joins, and for a joined transaction `TransactionalJtaTransactionPolicy.rollback(false)` calls `transactionManager.setRollbackOnly()`, so the outer `commit()` fails with `CamelException: Unable to commit transaction`. The guide now says: if the `transacted()` block in which the exchange is marked rollback only last joins the transaction of an outer block (for example a `PROPAGATION_MANDATORY` block inside a `PROPAGATION_REQUIRED` block), that shared JTA transaction is now marked rollback only, so the outer commit fails where it used to commit, as with camel-spring (`UnexpectedRollbackException`). To roll back only the inner block, use `PROPAGATION_REQUIRES_NEW` for it. I used `PROPAGATION_MANDATORY` in the example rather than two `PROPAGATION_REQUIRED` blocks: in Camel Quarkus `PROPAGATION_REQUIRED` is a single bean, and an inner `transacted()` with the same policy bean is not a transaction boundary of its own (`isTransactedBy(transactionKey)`), so there the outer error handler sees the marker and rolls back the one transaction. _Claude Code on behalf of allthingssecurity_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
