Unlocking the Power of Scheduled Jobs in Spring Boot
āļāļąāļ
- āđāļāļĒāđāļāļĢāđāđāļĄāļ·āđāļ 4 āļŠ.āļ. 2024
- Today we have another bit of a fullstack demo for those new to using Java Spring Boot. We'll be looking at Scheduled Jobs, also known as Scheduled Tasks.
There are 3 options when using Scheduled in Java Spring Boot, and we'll go through all 3:
1. FixedDelay - The same thread executes the Job. If the thread is busy when the next execution is timed to occur, Spring Boot will wait until the thread is complete
2. FixedRate - The Job is executed by a different thread, with the help of "Async" annotation. This means that even when a Job has not finished before the next execution is launched, Spring Boot will create it using a different thread
3. Cron - Similar to Unix / Linux sysadmin work, we can use a "cron" expression to schedule a Job
I hope you have a lot of fun with this project, and that it inspires you to pursue your own creative design!
ððGrab the source! github.com/wazooinc/spring-bo...
ðGrab My Other Products Available:
- Packaging a JavaScript Frontend in Java Spring Boot: t.ly/gaKyT
- Build Your First Web Service with Java Spring Boot: t.ly/iv_84
ððŧConnect with me:
Twitter: / eyuzwa
ðReferences:
- Docker Desktop Client: www.docker.com/
- Cron Reference: crontab.cronhub.io/
===---=== Chapters ===---===
00:00 - Introduction
00:13 - What are Scheduled Jobs?
01:14 - Generate Project
02:05 - Setting up Project Basics
06:01 - Sketching out the ProductInventoryJob
07:45 - a FixedDelay Scheduled Job
09:40 - @EnableScheduling
10:55 - a FixedRate Scheduled Job
12:42 - @EnableAsync
13:18 - Checking the Database
14:31 - a Cron Scheduled Job
#springboot #docker #scheduledjobs - āļ§āļīāļāļĒāļēāļĻāļēāļŠāļāļĢāđāđāļĨāļ°āđāļāļāđāļāđāļĨāļĒāļĩ
It's about "Time" we covered scheduled jobs! Hope this was useful for your current project!
Thanks for the video. Big thumbs up!ððð
thanks so much! I appreciate that!
Please create a very detailed course series for beginners to professional level on spring boot, mysql, Database design, migrations, caching, redis, docker. You can build one big project from small to complete or small projects to explain and show demos. Please.
thanks for the suggestion, that's some good ideas!
Hi, thank you for tutorial! Btw, why did you use Atomic integer? Is there any benefits of using .forEach() instead of for-i in this case?. In for-i loop you could use a simple primitive int.
No real benefit - at first I thought it might be safer given that it's running in a job context, but I updated the git repo with your suggestion and it also seems to work just fine. Thanks a lot for the feedback!