DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Providing Hystrix Fallbacks for Routes in Zuul

Providing Hystrix Fallbacks for Routes in Zuul

Read on for somes insight into utilizing fallbacks for Zuul routes in a Netflix OSS implementation of Spring Cloud.

Ryan Baxter user avatar by
Ryan Baxter
·
Nov. 17, 16 · News
Like (3)
Save
Tweet
Share
8.21K Views

Join the DZone community and get the full member experience.

Join For Free

If you are a user of Zuul from Spring Cloud Netflix, then you likely know that all the routes you configure that use Ribbon are also wrapped in Hystrix commands. This nice little feature provides a circuit breaker for all your proxied requests through Zuul. When the circuit is tripped it can save the proxied service from becoming too overloaded and perhaps also save your app from appearing to be “slow”.

If you have ever looked at Hystrix before, you know that you can generally provide a fallback for the circuit. The fallback provides some default functionality for the circuit when the circuit is tripped. For example, if you wrap a request to a service in a Hystrix Command and provide a fallback, than when the circuit is tripped and a request is made to the service the fallback will be invoked instead. What would the fallback return? One logical response would be to return back a cached response. This combination of circuit breaker + fallback allows for the downstream service to recover while still providing a somewhat meaningful response back to the calling service.

Up until now, it was not possible to provide a fallback when a circuit was tripped for a given route in Zuul. The latest Camden snapshot builds now include a feature allowing you to specify fallbacks for your routes configured in Zuul. (All releases prior to, and including Camden.SR1 do NOT include this functionality.) It is very simple to provide a fallback for a route in Zuul. All you have to do is provide a bean that implements ZuulFallbackProvider in your app. Within that bean, you specify the route ID you want the fallback to apply to and provide a ClientHttpResponse object to return when the fallback is invoked. For more information see the Spring Cloud docs. If you would like to see a working example check out the Zuul Server sample on GitHub.

zuul

Published at DZone with permission of Ryan Baxter, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Core Machine Learning Metrics
  • Public Cloud-to-Cloud Repatriation Trend
  • Promises, Thenables, and Lazy-Evaluation: What, Why, How
  • Simulate Network Latency and Packet Drop In Linux

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: