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

Claus Ibsen commented on CAMEL-20290:
-------------------------------------

I think SB auto-configure configures the default values, so 20 will be set even 
that it was not declared in application.properties

> 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.x
>            Reporter: John Poth
>            Priority: Minor
>
> 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)

Reply via email to