spring-cloud-gateway
spring-cloud-gateway copied to clipboard
Why RouteRefreshListener is added automatically?
When i add "spring-cloud-starter-netflix-eureka-client",then SCG add RouteRefreshListener,which refresh routes definition automatically by publishing heartbeat event,is that problem,caus i don't want to refersh routes definition every heartbeat!
i think, because spring.cluod.gateway.predicate.cloud-foundry-route-service.enable is true new service will join, old service may left.
In GatewayDiscoveryClientAutoConfiguration class:
@Bean
@ConditionalOnClass(name = "org.springframework.cloud.client.discovery.event.HeartbeatMonitor")
public RouteRefreshListener routeRefreshListener(ApplicationEventPublisher publisher) {
return new RouteRefreshListener(publisher);
}
I can not understand what is the relationship between HearbeatMonitor and RouteRereshListener!
See https://github.com/spring-cloud/spring-cloud-gateway/blob/71014d10bfa040a08d3479b161b79b3c8cd0d4a8/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/route/RouteRefreshListener.java#L56-L63
We do this so routes located from discovery can be refreshed. Perhaps it should only be active if spring.cloud.gateway.discovery.locator.enabled=true