[
https://issues.apache.org/jira/browse/CAMEL-24072?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen updated CAMEL-24072:
--------------------------------
Fix Version/s: 4.22.0
> camel-jms: component-level transacted=true breaks ConnectionFactory
> autowiring - startup fails with "connectionFactory must be specified"
> -----------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-24072
> URL: https://issues.apache.org/jira/browse/CAMEL-24072
> Project: Camel
> Issue Type: Bug
> Components: camel-jms
> Affects Versions: 4.21.0
> Reporter: Federico Mariani
> Assignee: Claus Ibsen
> Priority: Major
> Labels: code-review
> Fix For: 4.22.0
>
> Attachments: JmsTransactedAutowiredConnectionFactoryTest.java
>
>
> h3. Problem
> {{JmsComponent.doInit()}} guards the registry ConnectionFactory autowiring
> with {{configuration.getOrCreateTransactionManager() == null}}
> (JmsComponent.java:1129). With {{transacted=true}} and the default
> {{lazyCreateTransactionManager=true}}, {{getOrCreateTransactionManager()}}
> *eagerly creates* a {{JmsTransactionManager}}
> (JmsConfiguration.java:1258-1263 -> 1877-1881), which calls
> {{getOrCreateConnectionFactory()}} -> {{createConnectionFactory()}} ->
> {{ObjectHelper.notNull(connectionFactory, "connectionFactory")}} - and
> throws, because the ConnectionFactory is still null: the registry autowiring
> that would supply it is the *body of the very if statement being evaluated*.
> h3. Failure scenario
> {{camel.component.jms.transacted=true}} plus exactly one
> {{ConnectionFactory}} bean in the registry (the standard camel-main / Spring
> Boot / Quarkus setup) -> context startup fails deterministically with
> {{IllegalArgumentException: connectionFactory must be specified}}. Removing
> {{transacted=true}} makes it start.
> Workaround: {{lazyCreateTransactionManager=false}}.
> h3. History
> The guard itself is CAMEL-14213 (intentional: don't autowire a CF when a TM
> is configured). CAMEL-14220 changed {{getTransactionManager()}} ->
> {{getOrCreateTransactionManager()}} to fix camel-activemq, whose
> {{createConnectionFactory()}} override builds a CF from {{brokerURL}} - plain
> camel-jms has no such override, so it throws instead. No test pins this.
> h3. Reproducer
> Attached {{JmsTransactedAutowiredConnectionFactoryTest.java}} (place in
> {{components/camel-jms/src/test/java/org/apache/camel/component/jms/}}). No
> broker needed - the failure happens during component initialization.
> ----
> _This issue was researched and filed by Claude Code on behalf of [~croway]
> (GitHub: Croway), as part of a deep code review of camel-jms and camel-amqp.
> A failing JUnit reproducer is attached; it fails deterministically on current
> main (4.22.0-SNAPSHOT)._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)