Alex Liroyd created CAMEL-15917:
-----------------------------------

             Summary: Resilience4j Property Component doesn't work for 
configurationRef
                 Key: CAMEL-15917
                 URL: https://issues.apache.org/jira/browse/CAMEL-15917
             Project: Camel
          Issue Type: Bug
    Affects Versions: 3.4.4
            Reporter: Alex Liroyd
         Attachments: stackTraceCamel.txt

I'm using camel-resilien4j library:
{code:xml}
<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>
{code}
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.
{code:xml}
  <circuitBreaker configurationRef="{{myName}}">
            <to uri="direct:someUri"/>
        </circuitBreaker>
{code}
 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
{code:java}
        if (definition.getConfigurationRef() != null) {
            final String ref = definition.getConfigurationRef();

            loadProperties(properties, Suppliers.firstNotNull(
                () -> 
camelContext.getExtension(Model.class).getResilience4jConfiguration(ref),
                () -> mandatoryLookup(ref, 
Resilience4jConfigurationDefinition.class)),
                configurer);
        }
 {code}
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:
{code:java}
        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);
        }
 {code}
 
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? 

 

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to