How it works...

Time-triggered or @Scheduled service transactions in Spring 5 are required to return void with no parameters. This recipe highlighted some transactions that run periodically using asynchronous threads configured through the annotation property fixedRate. On the other hand, the service batchFixedDelay() runs asynchronously with a fixed delay of 1000 milliseconds defined by the property fixedDelay.

With regard to delay features, some batch processes can be configured to execute after a fixed period of time with some initial delays determined by the initialDelay property, as depicted in batchInitialDelay() implementation.

But the most detailed, flexible, and manageable way of implementing @Scheduled native services is through the cron configuration wherein a cron expression is used to schedule the transaction. Depending on the requirement, the cron can be easily be adjusted whenever changes happen.

The asynchronous behavior of these scheduled events is attributed to the TaskScheduler which manages and delegates threads to every @Scheduled service. It is also responsible for causing all the triggers defined in the @Scheduled to materialize. This TaskScheduler must be injected into the SchedulingConfigurer through the overridden method configureTasks().

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.199.181