package com.fzzy.gateway; import com.fzzy.api.data.ApiParam; import com.fzzy.api.entity.ApiConfs; import com.fzzy.api.service.*; import com.fzzy.api.utils.ContextUtil; import com.fzzy.api.utils.RedisUtil; import com.fzzy.gateway.api.GatewayRemoteManager; import com.fzzy.gateway.entity.GatewayConf; import com.fzzy.gateway.service.GatewayConfService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.time.DateUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import javax.annotation.Resource; import java.util.Date; import java.util.List; /** * 网关相关的定时器 */ @Slf4j @Component(GatewayTimerScheduled.BEAN_ID) public class GatewayTimerScheduled { public static final String BEAN_ID = "gateway.timerScheduled"; @Resource private GatewayConfService confService; @Resource private GatewayRemoteManager gatewayRemoteManager; /** *
* 固定时间:每间隔10分钟执行一次
*/
@Scheduled(cron = "0 0/10 * * * ? ")
public void scheduled() {
//网关的心跳执行
doHeartbeat();
}
/**
* 执行网关心跳
*/
private void doHeartbeat() {
//获取缓存中的网关信息
List