Solve SpringCloud Gateway Finchley.SR2 service is down, do not go blowing reported fallbackCmd failed and fallback failed. Issues

In the project, met Gateway Gateway Routing service is down, but in the end did not go to redirect blown.

Gateway has a configuration file in application.yml in:

filters:

            - RewritePath=/olesellercenter/(?<segment>.*), /$\{segment} 

    # Routing rewrite

            - name: Hystrix                  

        # Fuse filter

              args:

                name: fallbackCmd  

                    # Conform to Java naming conventions

                fallbackUri: forward:/fallback/serviceFailurePage 

        # Server access fails, there will fuse, which is a redirect

 

Configuring the fuse, if the service goes down, the route is less than the service will be blown away. Make yourself a Controller handle the forwards, as follows:

@RestController

@RequestMapping("/fallback")

public class FallbackController {

 

@GetMapping("/sellercenter")

public String fallback() {

return "Merchant Services is busy, please try again later" ;

}

}

However, in practice, will be reported in a very strange question, it is that we can handle the request GET method, that is, when the service is down,

GET method to go gateways, access service, there will fuse mechanism

, Will be reported "Merchant Services is busy, please try again later", but POST method request, will not be blown away, I was baffled.

Then think about this since I was there GetMapping Controller

Mapped. The reason is not a lack of PostMapping mapping results, then add PostMapping map, it really solved the problem.

which is:

@RestController

@RequestMapping("/fallback")

public class FallbackController {

 

@GetMapping("/sellercenter")

public String fallback() {

return "Merchant Services is busy, please try again later" ;

}

 

@PostMapping("/sellercenter")

public String postFallback() {

return "Merchant Services is busy, please try again later" ;

}

}

 

Later, think about it: When gateway access to post way through the service, service downtime, Gateway at this time will be redirected, blown away,

Will be at the client's request to take the post fuse, and his handlers did not PostMapping Controller mapping mechanism in a manner so do not go blowing Post request will appear.

Read a lot of information online, there are many similar problems, want to have the same problem of a small partner to see this article, you can solve your problem! ! !

 

Guess you like

Origin www.cnblogs.com/jinshuaishuai/p/10936437.html