davsclaus opened a new pull request, #28123:
URL: https://github.com/apache/camel/pull/28123

   [CAMEL-25767](https://issues.apache.org/jira/browse/CAMEL-25767): with 
`camel run --dev`, a change to application.properties did not apply its beans 
and components. One save that adds a JMS connection, as a coding agent writes 
it, failed:
   
   ```properties
   camel.beans.artemisCF = 
#class:org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory
   camel.beans.artemisCF.brokerURL = tcp://localhost:61616
   camel.component.jms.connection-factory = #bean:artemisCF
   ```
   
   ```
   java.lang.IllegalArgumentException: connectionFactory must be specified
   ```
   
   After a restart, the same files worked. There were two causes.
   
   ## 1. The changed file did not match the file the application loaded
   
   `camel run --source-dir=.`, which the AI tools use, loads 
`file:./application.properties`, and the file watcher reports 
`file:application.properties`. `RouteWatcherReloadStrategy` compared the two as 
text. So `PropertiesComponent.reloadProperties` found nothing to reload, and 
the file was added once more, as a source of property placeholders. The 
placeholders took the new values, but the `camel.component.*`, 
`camel.dataformat.*` and `camel.language.*` options in the file were never 
applied, although camel-main does apply them again on a reload 
(`MainPropertiesReload`).
   
   - The file is matched to a location of the properties component by its 
normalized path.
   - A properties file that is created while the application runs is applied as 
well. It was only added for its placeholders.
   
   ## 2. A reload did not create beans
   
   `MainPropertiesReload` applies components, data formats and languages again, 
but not `camel.beans.*`. So `#bean:artemisCF` referred to a bean that the 
reload never created.
   
   - New beans (a name that is not in the registry) are created and bound as 
when the application starts, before the components are configured again. A 
component can then refer to them, and a component that is created later can 
autowire them (as jms does with one connection factory). The class is 
downloaded when needed, as at startup: camel-jbang knows 
`org.apache.activemq.artemis`.
   - A bean that exists is left as it is, as components and routes may hold it. 
When its properties change in a file, a `WARN` says that a restart is needed.
   - A context reload (secret rotation, `camel.main.context-reload-enabled`) 
goes through the same `MainPropertiesReload`, but hands over every option with 
a property placeholder each time. So it must not warn about the beans. 
`PropertiesReload` gets a default method `onChanged(name, properties)`, which 
the file watcher calls with the properties that changed. The default calls 
`onReload`, so other implementations behave as before.
   
   ## Tests
   
   - New `RouteWatcherReloadPropertiesLocationTest` (camel-core, 2): the 
changed file reaches the listener under the location that the properties 
component knows (`<dir>/./app.properties` for `<dir>/app.properties`), and is 
not added a second time; a new properties file reaches it too. Without the fix, 
the listener gets nothing in both.
   - New `MainPropertiesReloadBeansTest` (camel-main, 3):
     - a new bean is created, and the log component of the same reload is 
configured with it;
     - a bean that exists is left as it is, with the WARN;
     - a context reload leaves it without a WARN.
     - Without the change in camel-main, the first fails with "No bean could be 
found in the registry for: myFormatter", as in the benchmark, and the second 
without the WARN.
   - End to end with the camel launcher built from this branch, `camel run 
--source-dir=. --dev`, and one save that adds the connection factory above 
(port 61699, where no broker runs), the jms component configured with it, and a 
route that sends to `jms:queue:orders`:
     - before: 36 times "connectionFactory must be specified";
     - after: "Binding bean: artemisCF (type: 
org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory)", and the 
route uses it: "AMQ219007: Cannot connect to server(s)" (no broker on that 
port);
     - the same when application.properties is created in that save.
   - The reload tests of camel-core pass (20), and all tests of camel-main 
(299).
   
   Found in a benchmark of Oct 18-19 2026: the JMS example 
(apache/camel-jbang-examples#115) adds the connection in application.properties 
while the application runs in dev mode.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m
   


-- 
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]

Reply via email to