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

Resilience4j Property Component doesn't work for configurationRef

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.4.4
    • 3.4.5, 3.7.0
    • came-core, camel-core, eip
    • None
    • Novice
    • Patch, Important

    Description

      I'm using camel-resilien4j library:

      <groupId>org.apache.camel.springboot</groupId>
      <artifactId>camel-spring-boot-dependencies</artifactId>
      <version>3.4.4</version>
      
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-resilience4j</artifactId>
      

      I want to use https://camel.apache.org/components/latest/properties-component.html

      functionality for circuit breaker configuration in camel routes definitions.

      It's needed to be able to add some specific route to some specific group. So I'm trying to do following.

        <circuitBreaker configurationRef="{{myName}}">
                  <to uri="direct:someUri"/>
              </circuitBreaker>
      

       But it doesn't work. myName is not resolved using property file. I can't hardcode names. 

      As I can see - ResilienceReifier doesn't even try to resolve it using config.

      ResilienceReifier#buildResilience4jConfiguration

              if (definition.getConfigurationRef() != null) {
                  final String ref = definition.getConfigurationRef();
      
                  loadProperties(properties, Suppliers.firstNotNull(
                      () -> camelContext.getExtension(Model.class).getResilience4jConfiguration(ref),
                      () -> mandatoryLookup(ref, Resilience4jConfigurationDefinition.class)),
                      configurer);
              }
       

      so definition (ref) is transferred as is. And it cause an issue, because there is no such config as myName.

      What I would expect to see, is:

              if (definition.getConfigurationRef() != null) {
      
           /// here is modified code
                  Optional<String> configuredValue = camelContext.getPropertiesComponent().resolveProperty(definition.getConfigurationRef();
                  final String ref = configuredValue.isPresent() ? configuredValue.get() : definition.getConfigurationRef();
          /// end of modified code
      
                  loadProperties(properties, Suppliers.firstNotNull(
                      () -> camelContext.getExtension(Model.class).getResilience4jConfiguration(ref),
                      () -> mandatoryLookup(ref, Resilience4jConfigurationDefinition.class)),
                      configurer);
              }
       

       
      It's simple lookup for configuration value, but it provides a huge flexibility for entire framework.

       

      Also, is there anyway, how I can temporary hotfix this issue, in order to proceed with development? 

       

       

      Attachments

        1. stackTraceCamel.txt
          3 kB
          Alex Liroyd

        Activity

          People

            Unassigned Unassigned
            Liroyd Alex Liroyd
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: