Issue
I have developed a springMVC application which uses ehcache. The cache items are fetched from another system. I would not know when will the items get change in the next system. I need to periodically trigger a webservice call say 5 hrs or 3 hrs interval in order to fetch the changed items and update in the cache.
Is it possible to refresh to bean in paricular interval so that upon refreshing i will invoke the webservices and refresh the cache.
Solution
Probably the easiest way to solve your problem is to create a periodically executed job that triggers the WebService call.
Something like this:
@Service
public class WebServiceRefreshService {
public static final int SERVICE_CALL_RATE_MILLISECONDS = 60 * 1000;
@Scheduled(fixedRate = SERVICE_CALL_RATE_MILLISECONDS)
public void refreshFromWebService() {
//do stuff
}
}
Answered By - WeMakeSoftware
Answer Checked By - Pedro (JavaFixing Volunteer)