Scheduling
22 questions in 5 subtopics.
@Scheduled
Explain the difference betweenfixedRate, fixedDelay and cron in @Scheduled, and what happens with fixedRate when one execution takes longer than the interval.A @Scheduled method in a Spring Boot service never runs, and there are no errors in the logs. List the likely causes.A Spring Boot service has three @Scheduled methods. One of them calls a slow external API that sometimes takes 10 minutes, and during that time the other two jobs do not run. Explain why and how to fix it.A team uses @Scheduled to send daily reminder emails from a Spring Boot service, and it worked until the service was scaled from 1 to 6 replicas. What happens now, and what options do you have?Teams across your organisation keep adding @Scheduled jobs inside request-serving services, which caused incidents when jobs competed with traffic or ran on every replica. What guidance would you set?Scheduling in clusters and ShedLock
Show how to make a@Scheduled method run on only one instance in a cluster using ShedLock with a JDBC lock provider, and explain lockAtMostFor and lockAtLeastFor.A ShedLock-protected job occasionally runs twice within a minute on different pods. The job takes 20 seconds and lockAtMostFor is 30 seconds. What are the possible causes?A team uses ShedLock to run a job that processes all pending invoices every minute, but the backlog keeps growing because only one pod works at a time. How would you redesign it to scale?You need a cluster-wide scheduling approach for 40 services, some running on Kubernetes and some on VMs. Compare ShedLock, Quartz clustering, Kubernetes CronJobs and a central scheduler service.A missed or duplicated scheduled job caused a costly incident at your company: interest was calculated twice for some accounts. As the senior technical leader, how do you address the systemic risk rather than this single bug?Your organisation is considering offering scheduling as a central platform service (triggers, calendars, history, alerting) instead of each team using @Scheduled with ShedLock, Quartz or CronJobs. As the senior technical leader, how do you decide whether to fund it and how to run it?Quartz
Describe the main concepts of Quartz (Job,JobDetail, Trigger, Scheduler) and how Spring Boot's spring-boot-starter-quartz wires them.A Quartz job scheduled every 5 minutes in a clustered JDBC job store sometimes runs concurrently with itself, and after a 1-hour outage it fired many times at once. Explain and fix both problems.Your team inherits a Quartz cluster with 2,000 triggers across 10 nodes, and the QRTZ tables have become a database hotspot with lock waits on QRTZ_LOCKS. What would you investigate and change?Your organisation is deciding whether teams should embed Quartz in their Spring Boot services or use a central job scheduling service. Compare the options for 50 teams.Cron expressions
Write Spring cron expressions for: every weekday at 06:30, every 15 minutes during business hours 9-17, and the last day of every month at 23:00. Explain how Spring cron differs from Unix cron.A job scheduled with@Scheduled(cron = "0 30 2 * * *") ran twice on one night and not at all on another night in spring. The servers use the Europe/Berlin time zone. Explain and fix.Thousands of jobs across your services are scheduled at midnight UTC, and every night the shared database and message broker overload for ten minutes. How would you fix this across teams?Your company operates in 30 countries and many scheduled processes depend on local business days and holidays. As the senior technical leader, how would you approach calendars and scheduling standards company-wide?Legacy Timer tasks
java.util.Timer and TimerTask are considered legacy. What are their problems, and what replaces them?Migrate this code to a modern alternative and explain the improvements:Timer t = new Timer();
t.scheduleAtFixedRate(new TimerTask() {
public void run() {
refreshCache();
}
}, 0, 60000);
java.util.Timer in 70 places across many services, and one past incident was caused by a Timer thread dying silently. How do you plan the clean-up?No question matches these choices.