Help Can't get CircuitBreaker to Fire

45 views
Skip to first unread message

Eric Miller

unread,
Nov 4, 2012, 10:04:34 AM11/4/12
to jrugge...@googlegroups.com
Hi - I'm new to this project and it looks fantastic.  I was trying to use @CircuitBreaker annotation on a method that as part of the test throws a runtime exception.  I would expect that after 5 failed attempts, the method would start throwing CircuitBreakerExceptions, but it doesn't. Any help or examples would be much appreciated.  I see TestClass.java in the jrugged-spring package as close to what I am trying to do.  Any help or tips would be much appreciated.  Note I also tried wiring through the autoproxy context per the other example and that didn't work either.


Java Code
    @CircuitBreaker(name = "interceptCircuitBreaker")
    @RequestMapping(value = "fis/{fiId}/fiCustomers/{fiCustomerId}/alerts", method = RequestMethod.GET)
    public Alerts handleGetAlerts(@PathVariable("fiId") String fiId,
            @PathVariable("fiCustomerId") String fiCustomerId) throws TimeoutException {
       
        if(fiId.equals("1111"))
            throw new RuntimeException("Request timed out");


ApplicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:oxm="http://www.springframework.org/schema/oxm"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
  http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
  http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.1.xsd">

    <context:component-scan base-package="com.my.services" />
   
    <mvc:annotation-driven/>


   
   
      <!--==============================
        Interceptors - Breaker
    ================================-->
    <bean id="interceptCircuitBreaker" class="org.fishwife.jrugged.spring.CircuitBreakerBean">
        <property name="limit" value="2"/>
        <property name="windowMillis" value="5000"/>
        <property name="resetMillis" value="10000"/>
    </bean>           
           

</beans>

Campbell, Joseph

unread,
Nov 4, 2012, 10:16:36 AM11/4/12
to jrugge...@googlegroups.com
Eric,
     The configuration states 2 errors in a 5 second window - can I assume that the errors that you are producing are inside that 5 second window?

<property name="limit" value="2"/>
<property name="windowMillis" value="5000"/>

Thanks,
     Joe

--
"The wise course is not to try to forestall change (to slow or stop it through regulation), but to accelerate it through openness and investment."
     -- Jeff Jarvis

Joe Campbell | one comcast center | philadelphia, pa 19103 | 215.286.5073

Eric Miller

unread,
Nov 4, 2012, 2:27:25 PM11/4/12
to jrugge...@googlegroups.com
Hi Joe - Yes that's correct, I'm forcing the code to error well more than twice every 5 seconds.

I've attached it - its a simple test service that I created.  If you have time you can unpack it into a directory, run mvn clean install and then navigate to the web directory and run mvn jetty:run

It pulls the JRUGGED artifacts from your local machine so you'd need those there first.
This command will work
http://localhost:8080/v1/fis/DI1234/fiCustomers/5678/alerts.json

this command will force the runtimeexception
http://localhost:8080/v1/fis/1111/fiCustomers/5678/alerts.json

Really appreciate any thoughts you might have  and thanks for the quick response

welcomeservice.zip

Eric Miller

unread,
Nov 4, 2012, 2:33:07 PM11/4/12
to jrugge...@googlegroups.com
Hi Joe -

Yes I am causing more than 2 runtime exceptions in 5 seconds.  I would expect the code to throw a circuitbreaker exception after the 2nd error but it does not.  The code is attached.  You can extract, run "mvn clean install", navigate to the web folder and run "mvn jetty:run". 


This URL works:  http://localhost:8080/v1/fis/DI1234/fiCustomers/5678/alerts.json
This URL causes the RuntimeException: http://localhost:8080/v1/fis/1111/fiCustomers/5678/alerts.json

ANy thoughts you can provide or sample code would be appreciated.
welcomeservice.zip

Eric Miller

unread,
Nov 4, 2012, 2:33:23 PM11/4/12
to jrugge...@googlegroups.com
welcomeservice.zip

Campbell, Joseph

unread,
Nov 4, 2012, 3:08:24 PM11/4/12
to jrugge...@googlegroups.com
Also eric it would appear that you are missing some spring configuration to 'enable' the annotations:

   <aop:aspectj-autoproxy proxy-target-class="true"/>

    <bean name="breakerBeanFactory"
          class="org.fishwife.jrugged.spring.CircuitBreakerBeanFactory">
        <property name="packageScanBase" value="com.my.services/>
    </bean>

    <bean name="circuitBreakerAspect"
          class="org.fishwife.jrugged.aspects.CircuitBreakerAspect">
        <property name="circuitBreakerFactory" ref="
breakerBeanFactory"/>
    </bean>

Lemme know if this helps,
      Joe

--
"The wise course is not to try to forestall change (to slow or stop it through regulation), but to accelerate it through openness and investment."
     -- Jeff Jarvis

Joe Campbell | one comcast center | philadelphia, pa 19103 | 215.286.5073

77759C3C-5C44-47C7-89A6-5C42E1EAACD7[16].png

Campbell, Joseph

unread,
Nov 4, 2012, 3:09:55 PM11/4/12
to Eric Miller, jrugge...@googlegroups.com
Posting to the group and cc'ing you (because I didn't do that originally)

MSG 1:
Eric,
     The configuration states 2 errors in a 5 second window - can I assume that the errors that you are producing are inside that 5 second window?

<property name="limit" value="2"/>
<property name="windowMillis" value="5000"/>

MSG 2:
Also eric it would appear that you are missing some spring configuration to 'enable' the annotations:

   <aop:aspectj-autoproxy proxy-target-class="true"/>

    <bean name="breakerBeanFactory"
          class="org.fishwife.jrugged.spring.CircuitBreakerBeanFactory">
        <property name="packageScanBase" value="com.my.services/>
    </bean>

    <bean name="circuitBreakerAspect"
          class="org.fishwife.jrugged.aspects.CircuitBreakerAspect">
        <property name="circuitBreakerFactory" ref="
breakerBeanFactory"/>
    </bean>

Lemme know if this helps,
      Joe

--
"The wise course is not to try to forestall change (to slow or stop it through regulation), but to accelerate it through openness and investment."
     -- Jeff Jarvis

Joe Campbell | one comcast center | philadelphia, pa 19103 | 215.286.5073

From: Eric Miller <ericwmill...@gmail.com>
Reply-To: "jrugge...@googlegroups.com" <jrugge...@googlegroups.com>
Date: Sunday, November 4, 2012 11:04 AM
To: "jrugge...@googlegroups.com" <jrugge...@googlegroups.com>
Subject: Help Can't get CircuitBreaker to Fire

Eric Miller

unread,
Nov 4, 2012, 8:13:00 PM11/4/12
to jrugge...@googlegroups.com
That was it.  Thanks so much for your time. 

Here's the configuration that worked...


<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-2.5.xsd
           http://www.springframework.org/schema/aop
            http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">

    <context:component-scan base-package="com.intuit.services" />

    <!--==============================
        Interceptors - Breaker
    ================================-->
    <aop:aspectj-autoproxy proxy-target-class="true"/>

    <bean name="breakerBeanFactory"
          class="org.fishwife.jrugged.spring.CircuitBreakerBeanFactory">
        <property name="packageScanBase" value="com.intuit.services"/>

    </bean>

    <bean name="circuitBreakerAspect"
          class="org.fishwife.jrugged.aspects.CircuitBreakerAspect">
        <property name="circuitBreakerFactory" ref="breakerBeanFactory"/>
    </bean>
   
   
    <bean id="interceptCircuitBreaker" class="org.fishwife.jrugged.spring.CircuitBreakerBean">
        <property name="limit" value="2"/>
        <property name="windowMillis" value="5000"/>
        <property name="resetMillis" value="10000"/>
    </bean>



</beans>

Campbell, Joseph

unread,
Nov 4, 2012, 8:14:47 PM11/4/12
to Eric Miller, jrugge...@googlegroups.com
That’s great Eric - Glad I could help.  We will be getting some additional documentation about this up onto the wiki in the coming days.

Thanks,
Joe Campbell

--
"The wise course is not to try to forestall change (to slow or stop it through regulation), but to accelerate it through openness and investment."
     -- Jeff Jarvis

Joe Campbell | one comcast center | philadelphia, pa 19103 | 215.286.5073

Date: Sunday, November 4, 2012 9:13 PM
To: "jrugge...@googlegroups.com" <jrugge...@googlegroups.com>
Reply all
Reply to author
Forward
0 new messages