1

I'm having an issue with this :

package com.acme;

Class CircuitBreakerUtil {

    public static boolean canAttempt(String breakerName) {
        return true;
    }
}

my spring declaration

<spring:bean id="circuitBreakerUtil" class="com.acme.CircuitBreakerUtil" scope="singleton"/>

my mvel expression :

             <choice doc:name="ApiCircuitBreakerName Is Up?">
        <when expression="#[app.registry.circuitBreakerUtil.canAttempt('ApiCircuitBreakerName')]">
                <flow-ref name="CircuitBreakerFlow" doc:name="CircuitBreakerFlow"/>
               <logger message="Passed CircuitBreakerFlow" level="INFO" doc:name="Logger"/>
        </when>
        <otherwise>
               <flow-ref name="EmailTechnicalSupportFlow" doc:name="EmailTechnicalSupportFlow"/>
               <flow-ref name="fallbackFlow" doc:name="fallbackFlow"/>
               <logger message="Passed FallbackFlow" level="INFO" doc:name="Logger"/>
        </otherwise>
    </choice>

and getting this error :

Caused by: [Error: unable to resolve method:     com.acme.CircuitBreakerUtil.canAttempt(java.lang.String) [arglength=1]]
[Near : {... app.registry.circuitBreakerUti ....}]
Pat B
  • 1,915
  • 23
  • 40
  • 1
    `Class CircuitBreakerUtil` is a typo or just to simplify the example? When I create a class without defining the access modifier, e.g.: `class CircuitBreakerUtil`, it introduces and error. If the access modifier is set, `public class CircuitBreakerUtil`, it works properly. – sulthony h Mar 10 '17 at 01:54
  • thank you for your help. I figured out that when I prefixed my method with "is" as to return a boolean, it worked. – Pat B Mar 10 '17 at 13:29

1 Answers1

0

Why can you try like below where you need

#[com.acme.CircuitBreakerUtil.canAttempt(param)] using MEL expression.

Even you can utilize your expressio component here.

Additionally you can declare this as a global expression and reuse it anywhere.

vijay dhanakodi
  • 175
  • 1
  • 14
  • This is not answering the question but rather proposing an alternative. It doesn't say what's wrong with the way of calling the object method from the MEL expression. – spoonboy Apr 06 '17 at 01:29