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