Posts

Showing posts from August, 2015

Spring Scheduler to Create Background Process to make Async Calls to Update Cache in Spring Boot

Image
Using Spring Scheduler to Create a Scheduled Task that hits your Endpoints to Update a Spring Cache for a Spring Boot Application

I used Spring Scheduler to execute a process on a regular basis to make separate async calls to several endpoints to keep the Spring cache updated and also as a health monitor.

This serves two purposes for us, we monitor all the endpoints to ensure correct data is coming back and it keeps the caches fresh and up to date even when there hasn't been traffic on that endpoint recently.

Guides on how to setup Spring caching:

https://spring.io/guides/gs/caching/http://codedevstuff.blogspot.com/2015/07/add-guava-cache-to-spring-boot-to-cache.html
Guide on Spring Scheduler:  http://spring.io/guides/gs/scheduling-tasks/

View all the code used in this article on Github here:
https://gist.github.com/anataliocs/61291ea9a96f8a642a61


The Spring Framework is maintained by Pivotal
+Spring by Pivotal
Spring Scheduler
You will want to add 3 annotations to your Application.j…