Spring Boot Scheduler | Spring Job Scheduler | @Scheduled Annotation | Async Scheduler

Sdílet
Vložit
  • čas přidán 25. 02. 2022
  • In this video, I will explain how the Spring @Scheduled annotation can be used to configure and schedule tasks and will explain about fixed rate, fixed delay, async scheduler and task scheduler.
    My Top Playlists:
    Spring Boot with Angular : • Spring Boot + Angular
    Spring Boot with Docker & Docker Compose : • Spring Boot Docker & D...
    Spring Boot with Kubernetes : • Spring Boot Docker Kub...
    Spring Boot with AWS : • Spring Boot + AWS
    Spring Boot with Azure : • Spring Boot Azure
    Spring Data with Redis : • Spring Data with Redis
    Spring Boot with Apache Kafka : • Apache kafka
    Spring Boot with Resilience4J : • SpringBoot Resilience4j
  • Věda a technologie

Komentáře • 18

  • @shwetabhat9981
    @shwetabhat9981 Před 2 lety +1

    It's great to see you back sir . Thank you for such amazing content 🎉🎉

  • @PsycheDevs
    @PsycheDevs Před rokem

    very helpful sir

  • @vamshikrishna2544
    @vamshikrishna2544 Před rokem

    Is there a way schedule a job and run to pull data from storage only once even when running on multiple instances? So it won’t pull same record twice before my update back to storage.

  • @yucolen
    @yucolen Před rokem

    Great video!
    Can you tell me how I could read this cron expression from a docker-compose?

  • @sarulatha7374
    @sarulatha7374 Před 2 lety +3

    How to schedule a task as per the end user request (like based on strat date or end date) using api call in springboot. Could you please make a video for that....It will be very useful

  • @stoicshubham8843
    @stoicshubham8843 Před rokem

    Can we use fixedRateString with minutes also and if so, then how to define that in this?

  • @PRAVEENPraveenkumar
    @PRAVEENPraveenkumar Před rokem

    Is there any way to schedule a job once not with postConstruct?

  • @PrashantZombade
    @PrashantZombade Před 7 měsíci

    Very well explained, thanks a lot for the hard work and sharing your knowledge.

  • @sunnymittal9542
    @sunnymittal9542 Před rokem

    Sir, your videos are very helpful. Request you to please upload more videos.

  • @lordgreat6051
    @lordgreat6051 Před 2 lety

    for some reason my fixedrate is also stopping for 2 seconds because of thread sleep despite having fixedrate value set to 1000 only
    Edit: never mind, i got it! so fixed rate does not have to work according to the given time to it! instead it only takes out that time out of the tread sleep so like if we give 3 sec to fixed rather and thread sleep is on 5 sec thenmethod will run each 2 sec because 3 out of 5 is 2

  • @manivasuppalamarthi6948
    @manivasuppalamarthi6948 Před 7 měsíci

    Very useful and informative. How to make jobs synchronous when application instance running on multiple nodes?

    • @technotowntechie9732
      @technotowntechie9732  Před 7 měsíci +1

      You might encounter scenarios where you want to ensure that a scheduled job is executed only once, regardless of the number of nodes. To achieve this, you can use a distributed locking mechanism. One popular approach is to use a distributed lock manager like Apache ZooKeeper or Redis.
      @Component
      public class ScheduledTask {
      @Autowired
      private RedisTemplate redisTemplate;
      @Autowired
      private RedisScript distributedLockScript;
      @Scheduled(cron = "0 0 1 * * ?") // Example cron expression
      public void scheduledJob() {
      String lockKey = "your-lock-key";
      String lockValue = "unique-value";
      // Attempt to acquire the lock
      Boolean lockAcquired = redisTemplate.execute(distributedLockScript, Collections.singletonList(lockKey), lockValue);
      if (lockAcquired != null && lockAcquired) {
      try {
      // Your scheduled job logic goes here
      } finally {
      // Release the lock when the job is done
      redisTemplate.delete(lockKey);
      }
      } else {
      // Another node already acquired the lock, skip this execution
      }
      }
      }
      Please refer the below link as well
      stackoverflow.com/questions/31288810/spring-scheduled-task-running-in-clustered-environment

  • @bhuvaneshwarib72
    @bhuvaneshwarib72 Před 5 dny

    Hi sir, how to get the server ip address when @cron is running in utility, i have used httpservlet request, but i am getting an exception

  • @deepseWorld
    @deepseWorld Před rokem +1

    LIKE LIKE LIKE LIKE

  • @cecilharper945
    @cecilharper945 Před 2 lety

    ᑭяỖmo??