在我们的组织中,目前我们正在使用基于mule的RAML API(版本3.9.0),它有CVE安全问题。因此,我们计划使用Spring Cloud Gateway更改我们的API。我有点非常新的这一点,因此探索网关功能之前,集成到实际应用程序。我在Retry GatewayFilter中遇到问题,它没有对配置的失败情况进行重试。这是我的配置
spring:
application:
name: tp-demo-ms
cloud:
gateway:
routes:
- id: demo-router
uri: http://localhost:8080/demo/hello/{name}
predicates:
- Path=/demo/hello/**
- Host=**10.1.0.0**
- Method=GET
filters:
- name: Retry
args:
retries: 3
statuses: BAD_GATEWAY, GATEWAY_TIMEOUT, INTERNAL_SERVER_ERROR,**NOT_FOUND**
methods: POST
backoff:
** firstBackoff: 10ms
maxBackoff: 50ms**
factor: 2
basedOnPreviousValue: false
我在调用另一个微服务时收到以下异常,
{“timestamp”:“2023-05-16T10:06:02.203+05:30”,“version”:“1”,“message”:“executed ==> '/demo/hello/' with status [404 Not Found]"}
在这方面的任何帮助是非常赞赏和感谢。
我试图命中端点http://localhost:8888/demo/hello/name
,它抛出404 NOT_FOUND异常。
但它没有按照我的重试回退配置进行重试。在我从我的控制台击中端点后,我可以看到没有重试发生。
1条答案
按热度按时间qvtsj1bj1#
我认为你应该用
uri : http://localhost:8080
替换uri : http://localhost:8080/demo/hello/{name}
,因为你已经用predicates : - Path : /demo/hello/**
匹配了路径我建议你阅读spring cloud gateway文档,非常有用。
https://cloud.spring.io/spring-cloud-gateway/reference/html/
此外,您可以使用Eureka 注册服务。