I have a monitoring app wherein I am running a fixedRate task. This is pulling in a config parameter configured with Consul. I want to pull in updated configuration, so I added @RefreshScope. But as soon as I update the config value on Consul, the fixedRate task stops running.
@Service
@RefreshScope
public class MonitorService {
@Autowired
private AppConfig appConfig;
@PostConstruct
public void postConstRun() {
System.out.println(appConfig.getMonitorConfig());
}
@Scheduled(fixedRate = 1000)
public void scheduledMonitorScan() {
System.out.println("MonitorConfig:" + appConfig.getMonitorConfig());
}
}
AppConfig class just has a single String parameter:
@Configuration
@Getter
@Setter
public class AppConfig {
@Value("${monitor-config:default value}")
private String monitorConfig;
}
As soon as I update the value in consul, the scheduled task just stops running (display in sheduledMonitorScan method) stop showing up.