Class SchedulerService

java.lang.Object
ai.nervemind.app.service.SchedulerService

@Service public class SchedulerService extends Object
Service for scheduling workflow executions. Uses virtual threads for efficient handling of many scheduled workflows.
  • Constructor Details

    • SchedulerService

      public SchedulerService(WorkflowService workflowService, ExecutionService executionService)
      Creates a new SchedulerService with the given dependencies.
      Parameters:
      workflowService - the workflow service for managing workflows
      executionService - the execution service for running workflows
  • Method Details

    • initialize

      @PostConstruct public void initialize()
      Initialize the scheduler by loading and scheduling all active workflows.
    • shutdown

      @PreDestroy public void shutdown()
      Shutdown the scheduler and cancel all scheduled tasks.
    • scheduleWorkflow

      public void scheduleWorkflow(ai.nervemind.common.dto.WorkflowDTO workflow)
      Schedule a workflow for execution based on its cron expression.
      Parameters:
      workflow - the workflow to schedule
    • cancelSchedule

      public void cancelSchedule(Long workflowId)
      Cancel a scheduled workflow.
      Parameters:
      workflowId - the ID of the workflow to cancel
    • rescheduleWorkflow

      public void rescheduleWorkflow(Long workflowId)
      Reschedule a workflow (call when workflow is updated).
      Parameters:
      workflowId - the ID of the workflow to reschedule
    • getActiveScheduleCount

      public int getActiveScheduleCount()
      Get count of active scheduled workflows.
      Returns:
      the number of currently scheduled workflows