You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "John Poth (Jira)" <ji...@apache.org> on 2024/01/03 13:38:00 UTC

[jira] [Created] (CAMEL-20290) Camel Spring Boot Starters configuration in Java and ConfigurationProperties conflict

John Poth created CAMEL-20290:
---------------------------------

             Summary: Camel Spring Boot Starters configuration in Java and ConfigurationProperties conflict
                 Key: CAMEL-20290
                 URL: https://issues.apache.org/jira/browse/CAMEL-20290
             Project: Camel
          Issue Type: Improvement
          Components: camel-spring-boot
    Affects Versions: 4.3.0
            Reporter: John Poth


It would be cool if we could find a way to reconcile:

1) Starter configurations via _ConfigurationProperties_
2) Stater configurations in Java

in a way that's clear for the user. For example the following configuration attempt in Java fails :
{code:java}
@Bean("http")
public HttpComponent http(){
    return ComponentsBuilderFactory.http()
                        .connectionsPerRoute(1).
                        .build();
}
{code}
As the _ConfigurationProperties_ kicks in afterwards and the _connectionsPerRoute_ will be set to the default 20 at runtime. The user can disable this by setting camel.component.http.customizer.enabled=false but that removes the ability to configure the component from application.properties files etc...

A workaround could be something like:
{code:java}
    @Bean("http")
    public HttpComponent myHttp(HttpComponentConfiguration config, CamelContext camelContext) {
        HttpComponent httpComponent = new HttpComponent();
        httpComponent.setCamelContext(camelContext);
        // copy external configuration
        CamelPropertiesHelper.copyProperties(camelContext, config, httpComponent);
        // Custom config
        httpComponent.setConnectionsPerRoute(1);
        return httpComponent;
    }
{code}
It would be also cool to have a clear priority order e.g if _connectionsPerRoute_ is set in Java and application.properties which takes precedence. Also, configuring multiple instances of the same component comes to mind.



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