spring-cloud-gateway icon indicating copy to clipboard operation
spring-cloud-gateway copied to clipboard

why publish RefreshRoutesResultEvent first

Open wangfeixianggithub opened this issue 2 years ago • 0 comments

when I consume the RefreshRoutesResultEvent, I try to get flux<Route> by the getRoutes() method but the cache miss. so there's a question ,why publish RefreshRoutesResultEvent first in CachingRouteLocator?

@Override
	public void onApplicationEvent(RefreshRoutesEvent event) {
		try {
			fetch().collect(Collectors.toList()).subscribe(
					list -> Flux.fromIterable(list).materialize().collect(Collectors.toList()).subscribe(signals -> {
						applicationEventPublisher.publishEvent(new RefreshRoutesResultEvent(this));
						cache.put(CACHE_KEY, signals);
					}, this::handleRefreshError), this::handleRefreshError);
		}
		catch (Throwable e) {
			handleRefreshError(e);
		}
	}

Describe the solution you'd like reverse the order

wangfeixianggithub avatar Jul 29 '22 03:07 wangfeixianggithub