Skip to content

Conversation

faizakram
Copy link
Owner

This pull request introduces a dynamic scheduler with a robust task locking mechanism to ensure safe and efficient execution of scheduled tasks in a distributed environment.

Key Features

  1. Dynamic Task Scheduling:

    • Enables dynamic scheduling of tasks based on configurations stored in the database.
    • Automatically initializes and schedules active tasks at application startup, allowing for real-time updates to scheduling configurations.
  2. Lock-Based Execution Control:

    • Utilizes a lock-based approach using LockProvider to manage task execution, ensuring that tasks are only executed when a lock is successfully acquired.
    • Prevents concurrent execution of the same task across multiple instances, improving data consistency and system reliability.
  3. Enhanced Lock Management:

    • Properly handles lock acquisition and release with robust error handling to prevent deadlocks and ensure that locks are released in all scenarios.
    • Supports configurable lock durations, offering flexibility in managing task execution windows.
  4. Simplified and Scalable Scheduling Logic:

    • Streamlines the scheduling logic using Spring's TaskScheduler and CronTrigger to provide flexible and scalable task scheduling options.
    • Easily extendable to accommodate future requirements or additional scheduling functionalities.

How to Test

To test the new dynamic scheduler implementation, you can use the following curl command to add a new schedule:

curl --location 'http://localhost:8080/schedule/add' \
--header 'Content-Type: application/json' \
--data '{
  "name": "Sample Schedule",
  "parameters": "param1=value1,param2=value2",
  "isActive": true,
  "day": 15,
  "scheduleType": "MINUTE"
}'

@faizakram faizakram added documentation Improvements or additions to documentation enhancement New feature or request labels Sep 4, 2024
@faizakram faizakram changed the title feat: Implement dynamic scheduler with robust task locking mechanism Implement dynamic scheduler with robust task locking mechanism Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants