This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Rust Web Development and have Bastian Gruber on-line!
See this thread for details.
Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Circuit breaker pattern implementation using Spring AOP

 
Ranch Hand
Posts: 30
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried if there is a way to implement circuit breaker pattern in java using spring framework. However i am in vain and couldn't get any online help for the implementation. Just want to know if anywhere this has been experienced. If so please share the experiences as well any online references.

I am thinking if I can implement using spring AOP. Please suggest if it can be implemented using Spring AOP or if there is any other way
 
krishna atok
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any suggestions/help please
 
Marshal
Posts: 5221
323
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm sure it can be done using AOP. Have you had any ideas on how you would do this?

Can you show us what you envisage the usage pattern to be? If I were using your circuit breaker library, how would I use it? I think that would be a good place to start.
 
Ranch Hand
Posts: 43
Spring Tomcat Server Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Spring AOP definitely is a good solution for this pattern.

You need to use the 'around' type of advice, or a combination of the other advices.

The 'around' type is probably the best for this case, as it looks like you will do monitoring most likely: after an execution, or when an exception is thrown, or, break the circuit before an execution, if the condition is met.

The condition will depend on a 'state'. You will therefore need the advice bean to be stateful, otherwise you will need a way to keep the state somewhere. An example of the 'state' is a count of how many failures has there been.


- j
 
krishna atok
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks John :-)

Can you help if there is any implementation available or any reference which can help me in acheiving this

Thanks
 
John Cruz
Ranch Hand
Posts: 43
Spring Tomcat Server Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have to be familiar with using Spring AOP. An example is in http://www.mkyong.com/spring3/spring-aop-aspectj-annotation-example/.

Spring documentation is in: http://docs.spring.io/spring/docs/current/spring-framework-reference/html/aop.html.

By the way, a great way to learn Spring AOP is to read the Spring In Action book chapter/s on AOP. Use the book edition based on Spring 4 if you will use spring 4. There is also a book version for spring 3, but spring 3 is quite relatively 'old' now.
 
krishna atok
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not clear with my previous question. What I need is any online reference which has implemented circuit breaker using Spring AOP. Hope I am clear now. Can you please help

Thanks,
 
Tim Cooke
Marshal
Posts: 5221
323
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not aware of any existing projects with available source code that does this. You might be able to find one if you search for it, but for learning purposes you'd be better to take John's advice and read up on Spring AOP, after which you'll know how to use it to solve your problem.
 
Honk if you love justice! And honk twice for tiny ads!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic