I am writing a task scheduling module in java spring to handle task items which are stored in Mysql database.
Schema structure of the Task table:
ID | TASK_UUID | TASK_CONTENT(VARCHAR) | CREATED_TS | UPDATED_TS | STATUS(NEW/PROCESSING/COMPLETE)
I would like to implement multiple task scheduler workers to get the tasks for execution from Task table. In what way I can ensure the task schedulers would not get the same task for execution at the same time? Any good java framework I can make use of?
#Edit 1: The task execution module is designed to be run by different machines, so sychronized methods may not work.
#Edit 2: Each machine will get random or irregular numbers of task. So if auto-increment sequence is used, the allocation size of the index should be irregular too, otherwise there will be some tasks being never handled.
#Edit 3: Each machine is running with Quartz Scheduler, configured with a constant Task getting and executing job. The time interval between every job is about 10 seconds. So, my goal is to ensure each machine scheduler can fetch at least 10 tasks in every quartz job run.