Update discovery client route definitionlocator documentation to use ReactiveDiscoveryClient
#2148 aperta il 16 feb 2021
Metriche repository
- Star
- (4284 star)
- Metriche merge PR
- (Merge medio 1g 21h) (18 PR mergiate in 30 g)
Descrizione
Describe the bug Per https://cloud.spring.io/spring-cloud-gateway/multi/multi__configuration.html#_discoveryclient_route_definition_locator
The Gateway can be configured to create routes based on services registered with a DiscoveryClient compatible service registry.
To enable this, set spring.cloud.gateway.discovery.locator.enabled=true and make sure a DiscoveryClient implementation is on the classpath and enabled (such as Netflix Eureka, Consul or Zookeeper).
In my mvce I wrote a simple discovery client and verified that it does get created using @PostConstruct. However the getInstances() and getServices() do not appear to be called. They return empty sets but there's a System.out to indicate that they are executed but I don't see it in the console logs.
Sample If possible, please provide a test case or sample application that reproduces the problem. This makes it much easier for us to diagnose the problem and to verify that we have fixed it.
2021-02-15 19:26:25.366 INFO 8128 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication using Java 12.0.2 on noriko with PID 8128 (D:\p\gateway-3\build\classes\java\main started by trajano in D:\p\gateway-3)
2021-02-15 19:26:25.369 INFO 8128 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default
2021-02-15 19:26:25.963 INFO 8128 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=23403c62-4898-30f2-a4fd-d673a77696b7
Hello world
2021-02-15 19:26:26.928 INFO 8128 --- [ main] o.s.c.g.r.RouteDefinitionRouteLocator : Loaded RoutePredicateFactory [After]
2021-02-15 19:26:26.928 INFO 8128 --- [ main] o.s.c.g.r.RouteDefinitionRouteLocator : Loaded RoutePredicateFactory [Before]
2021-02-15 19:26:26.928 INFO 8128 --- [ main] o.s.c.g.r.RouteDefinitionRouteLocator : Loaded RoutePredicateFactory [Between]
2021-02-15 19:26:26.928 INFO 8128 --- [ main] o.s.c.g.r.RouteDefinitionRouteLocator : Loaded RoutePredicateFactory [Cookie]
2021-02-15 19:26:26.928 INFO 8128 --- [ main] o.s.c.g.r.RouteDefinitionRouteLocator : Loaded RoutePredicateFactory [Header]
2021-02-15 19:26:26.928 INFO 8128 --- [ main] o.s.c.g.r.RouteDefinitionRouteLocator : Loaded RoutePredicateFactory [Host]
2021-02-15 19:26:26.928 INFO 8128 --- [ main] o.s.c.g.r.RouteDefinitionRouteLocator : Loaded RoutePredicateFactory [Method]
2021-02-15 19:26:26.928 INFO 8128 --- [ main] o.s.c.g.r.RouteDefinitionRouteLocator : Loaded RoutePredicateFactory [Path]
2021-02-15 19:26:26.929 INFO 8128 --- [ main] o.s.c.g.r.RouteDefinitionRouteLocator : Loaded RoutePredicateFactory [Query]
2021-02-15 19:26:26.929 INFO 8128 --- [ main] o.s.c.g.r.RouteDefinitionRouteLocator : Loaded RoutePredicateFactory [ReadBody]
2021-02-15 19:26:26.929 INFO 8128 --- [ main] o.s.c.g.r.RouteDefinitionRouteLocator : Loaded RoutePredicateFactory [RemoteAddr]
2021-02-15 19:26:26.929 INFO 8128 --- [ main] o.s.c.g.r.RouteDefinitionRouteLocator : Loaded RoutePredicateFactory [Weight]
2021-02-15 19:26:26.929 INFO 8128 --- [ main] o.s.c.g.r.RouteDefinitionRouteLocator : Loaded RoutePredicateFactory [CloudFoundryRouteService]
2021-02-15 19:26:27.053 INFO 8128 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 1 endpoint(s) beneath base path '/actuator'
2021-02-15 19:26:27.659 INFO 8128 --- [ main] o.s.b.web.embedded.netty.NettyWebServer : Netty started on port 8080
2021-02-15 19:26:28.242 INFO 8128 --- [ main] com.example.demo.DemoApplication : Started DemoApplication in 3.423 seconds (JVM running for 4.034)