Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-20290

Camel Spring Boot Starters configuration in Java and ConfigurationProperties conflict

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 4.x
    • None
    • camel-spring-boot
    • None
    • Unknown

    Description

      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 :

      @Bean("http")
      public HttpComponent http(){
          return ComponentsBuilderFactory.http()
                              .connectionsPerRoute(1).
                              .build();
      }
      

      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:

          @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;
          }
      

      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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jpoth John Poth
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: