davsclaus opened a new pull request, #29629:
URL: https://github.com/apache/camel/pull/29629
A route that uses `transacted` needs a transaction manager. Spring Boot and
Quarkus set one up; Camel Main and `camel run` do not. With spring-tx on the
classpath, such a route failed to start ("No bean could be found in the
registry for: org.springframework.transaction.PlatformTransactionManager"), and
under `camel run` it ran without a transaction (CAMEL-26850).
**What changes**
- camel-core: when `transacted` finds no policy and no
`PlatformTransactionManager`, but the registry has exactly one `DataSource` and
spring-jdbc is on the classpath, Camel creates a `JdbcTransactionManager` for
that `DataSource`. It binds it as `transactionManager` (unless that name is
taken), so the other transacted routes use the same one, and makes the
`SpringTransactionPolicy` of it as before. Without exactly one `DataSource`, or
without spring-jdbc, nothing changes: the route fails as before.
- `camel run`: when the `transacted` has no policy of its own, the registry
has no transaction manager but one `DataSource` (such as the one from
`spring.datasource.*`), and spring-jdbc is on the classpath (the sql component
brings it), the CLI downloads camel-spring instead of binding the placeholder
of CAMEL-26850. The placeholder and its WARN stay for the other cases, and the
WARN now says what gives transactions.
- The transactional client page explains the convention: the SQL and Spring
JDBC components take part in the transaction, as they get their connections
through Spring; the JDBC component does not.
**Tests**
- New `SqlTransactedLocalTransactionManagerTest` (camel-sql, H2, only a
`DataSource` in the registry): two inserts commit; a failing second insert
rolls back the first; the local transaction manager is bound with the
`DataSource`. With the reifier before this change the route fails to start
(NoSuchBeanTypeException for PlatformTransactionManager).
- `SqlTransactedRouteTest` (an explicit policy) still passes, and
camel-core's transacted, policy and transaction tests pass (136).
- `TransactedDownloaderTest`: one `DataSource` with spring-jdbc gives the
local transaction manager; none, two, a `ref` or a policy of the user's own do
not. camel-kamelet-main: 72 tests, 0 failures, 8 skipped (manual). spring-jdbc
is a new test dependency of camel-kamelet-main.
Not checked end to end with `camel run` yet: the `spring.datasource.*`
DataSource is bound on `CamelContextInitializingEvent`, before the routes are
built, so the check sees it. The transactions example of the local-model
benchmark will exercise this.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_016Y4dDi5iQNgtHrDdz2NpwF
--
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]