Let's say you have a task which you execute every 15 minutes and which usually takes few minutes to run. Its main purpose is to prevent execution from multiple nodes in case of really short tasks and clock difference between the nodes.Īll the annotations support Spring Expression Language (SpEL). Lastly, you can set lockAtLeastFor attribute which specifies minimum amount of time for which the lock should be kept. If you do not specify lockAtMostFor in default value from will be used. LockAtMostFor the resulting behavior may be unpredictable (more than one process will effectively hold the lock). You have to set lockAtMostFor to a value which is much longer than normal execution time. This is just a fallback, under normal circumstances the lock is released as soon the tasks finishes. ![]() You can also set lockAtMostFor attribute which specifies how long the lock should be kept in case theĮxecuting node dies. Only one task with the same name can be executed You also have to specify the name for the lock. First of all, only annotated methods are locked, the library ignoresĪll other scheduled tasks. To assert that the lock is held (prevents misconfiguration errors) LockAssert. SchedulerLock( name = "scheduledTaskName")
0 Comments
Leave a Reply. |