增加门店服务路由配置
This commit is contained in:
@ -0,0 +1,20 @@
|
||||
package com.sczx.gateway.component;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.gateway.event.RefreshRoutesEvent;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class DynamicRouteScheduler {
|
||||
|
||||
@Autowired
|
||||
private ApplicationEventPublisher publisher;
|
||||
|
||||
// 每30秒刷新一次路由(可按需调整)
|
||||
@Scheduled(fixedRate = 30_000)
|
||||
public void refreshRoutes() {
|
||||
publisher.publishEvent(new RefreshRoutesEvent(this));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user