Changes in Zuul fallback method in spring Cloud:Edgware.RELEASE version

Source: Internet
Author: User

In previous versions of Edgware.release, the Zuul Gateway had a Zuulfallbackprovider interface with the following code:

Public interface Zuulfallbackprovider {/** * The route this fallback would be a used for. * @return The route the fallback WI ll be used for. */public String Getroute ();/** * provides a fallback response. * @return the fallback response. */public clienthttpresponse fallbackresponse ();}

where the Fallbackresponse () method allows the programmer, in the fallback process, to reconstruct the output object, usually the output "XXX service is not available, please retry" such as the prompt, but unable to capture a more detailed error message, troubleshooting is inconvenient.

It is estimated that the Spring-cloud team is aware of this problem, marking the interface as obsolete @deprecated in Edgware.release and deriving a new interface underneath it:

Public interface Fallbackprovider extends Zuulfallbackprovider {/** * Provides a fallback response based on the cause of T He failed execution. * * @param cause cause of the main method failure * @return The fallback response */clienthttpresponse Fallbackresponse (Th Rowable cause);}

A new overloaded version is provided, and the exception information is passed in as a parameter, which is much more friendly and can output more detailed information when processing a fallback. Refer to the following code:

if (cause! = null && cause.getcause () = null) {        String reason = Cause.getcause (). GetMessage ();        Output verbose fallback reason ...        }

Changes in Zuul fallback method in spring Cloud:Edgware.RELEASE version

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.