[ 
https://issues.apache.org/jira/browse/CAMEL-25767?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18128841#comment-18128841
 ] 

Claus Ibsen commented on CAMEL-25767:
-------------------------------------

What it was, found while fixing it. There were two causes:

# With {{camel run --source-dir=.}}, which the AI tools use, the application 
loads {{file:./application.properties}}, and the file watcher reports 
{{file:application.properties}}. {{RouteWatcherReloadStrategy}} compared the 
two as text, so a changed application.properties was never applied: it was only 
added once more, as a source of property placeholders. So {{camel.component.*}} 
options (and data formats and languages) were not applied either, not only 
{{camel.beans.*}}. The description is wrong there: camel-main does apply these 
options again on a reload ({{MainPropertiesReload}}), when the file matches.
# The reload of camel-main ({{MainPropertiesReload}}, which a context reload 
uses too) did not create {{camel.beans.*}}.

The fix:
* The file is matched by its normalized path, and a properties file that is 
created while the application runs is applied as well.
* New beans are created and bound before the components are configured again. 
The class is downloaded when needed, as at startup 
({{org.apache.activemq.artemis}} is a known library).
* A bean that exists is left as it is, with a WARN when its properties change 
in a file.
* {{PropertiesReload}} gets a default method {{onChanged}} for a file that 
changed, so a context reload (secret rotation) does not warn.

Checked with {{camel run --source-dir=. --dev}} and one save that adds an 
Artemis connection factory, the jms component configured with it, and a jms 
route:
* Before: "connectionFactory must be specified".
* After: the bean is bound and the route uses it ("AMQ219007: Cannot connect to 
server(s)", as no broker runs on that port).

_Claude Code on behalf of davsclaus_

> camel-jbang - camel run --dev: a reload does not apply new camel.beans and 
> camel.component properties
> -----------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-25767
>                 URL: https://issues.apache.org/jira/browse/CAMEL-25767
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-jbang
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 4.24.0
>
>
> In camel run --dev, a change to application.properties is reloaded, but new 
> bean and component settings in it are not applied. For example, adding a JMS 
> connection to a running application:
> {code}
> camel.beans.artemisCF = 
> #class:org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory
> camel.beans.artemisCF.brokerURL = tcp://localhost:61616
> camel.beans.artemisCF.user = artemis
> camel.beans.artemisCF.password = artemis
> camel.component.jms.connection-factory = #bean:artemisCF
> {code}
> together with a route that uses jms, written in the same save. The reload 
> creates the jms component without the connection factory:
> {noformat}
> FailedToStartRouteException: Failed to start route: reserve-order (source: 
> jms-request-reply.camel.yaml:31) because: connectionFactory must be specified
> {noformat}
> After a restart, the same files work. The reload updates the values of 
> property placeholders, but camel.beans.* and camel.component.* are applied 
> only when the application starts. A user or a coding agent that adds a 
> connection this way gets an error that points at the route, not at the reload.
> Proposal: on a reload, apply new camel.beans.* properties (create the bean, 
> and download the dependency of its class as at startup) and the 
> camel.component.* properties of components that are not created yet. Where 
> that is not possible, log that these properties need a restart.
> Found while adding a JMS example to the AI benchmark 
> (apache/camel-jbang-examples#115).
> _Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to