Class CronWorkflow

    • Constructor Detail

      • CronWorkflow

        protected CronWorkflow​(String type,
                               WorkflowSettings settings)
        Extend cron workflow definition with customized workflow settings. It is recommended to enable the workflow state and action history cleanup. Extending class must implement the 'doWork` state method. For example:
         public NextAction doWork(StateExecution execution) {
           // do the work here
           return NextAction.moveToState(schedule, "Work done");
         }
         
        Parameters:
        type - The type of the workflow.
        settings - The workflow settings.
      • CronWorkflow

        protected CronWorkflow​(String type)
        Extend cron workflow definition. Uses workflow settings that enable automatic workflow state and action history cleanup (delete history older than 45 days, run cleanup once per day). Extending class must implement the 'doWork` state method. For example:
         public NextAction doWork(StateExecution execution) {
           // do the work here
           if (rescheduleImmediately) {
             return NextAction.moveToState(schedule, "Work done");
           }
           return NextAction.moveToStateAfter(waitForWorkToFinish, DateTime.now().plusHours(hoursToWait), "Waiting for work to finish");
         }
         
        Parameters:
        type - The type of the workflow.
    • Method Detail

      • getNextActivationTime

        protected org.joda.time.DateTime getNextActivationTime​(StateExecution execution,
                                                               String cron)
        Calculates next activation time based on cron state variable. Override for custom scheduling.
        Parameters:
        execution - The workflow execution context.
        cron - The cron schedule.
        Returns:
        The next activation time.
      • handleFailureImpl

        protected boolean handleFailureImpl​(StateExecution execution)
        Logs an error and continues. Override for custom error handling.
        Parameters:
        execution - The workflow execution context.
        Returns:
        True if workflow should be rescheduled. False to go to failed state and wait for manual actions.
      • waitForWorkToFinishImpl

        protected org.joda.time.DateTime waitForWorkToFinishImpl​(StateExecution execution)
        Returns null to move to schedule state immediately if there are no incomplete child workflows, or current time plus 1 hour to check again later. Override for custom logic.
        Parameters:
        execution - The workflow execution context.
        Returns:
        Time when check should be retried. Null to go to schedule state immediately.