public abstract class CronWorkflow extends WorkflowDefinition<CronWorkflow.State>
| Modifier and Type | Class and Description |
|---|---|
static class |
CronWorkflow.State
States of cron workflow.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
VAR_SCHEDULE
Name of the state variable that stores schedule in cron syntax.
|
allowedTransitions, failureTransitions| Modifier | Constructor and Description |
|---|---|
protected |
CronWorkflow(String type)
Extend cron workflow definition.
|
protected |
CronWorkflow(String type,
WorkflowSettings settings)
Extend cron workflow definition with customized workflow settings.
|
| Modifier and Type | Method and Description |
|---|---|
protected org.joda.time.DateTime |
getNextActivationTime(StateExecution execution,
String cron)
Calculates next activation time based on cron state variable.
|
NextAction |
handleFailure(StateExecution execution)
Tries to handle failures by calling
handleFailureImpl(io.nflow.engine.workflow.definition.StateExecution). |
protected boolean |
handleFailureImpl(StateExecution execution)
Logs an error and continues.
|
NextAction |
schedule(StateExecution execution,
String cron)
Determines the next execution time for the doWork state by calling
getNextActivationTime. |
NextAction |
waitForWorkToFinish(StateExecution execution)
Calls
waitForWorkToFinishImpl(io.nflow.engine.workflow.definition.StateExecution) to check if this instance should wait for work to finish or move to schedule state. |
protected org.joda.time.DateTime |
waitForWorkToFinishImpl(StateExecution execution)
Returns null to move to schedule state immediately if there are no incompleted child workflows, or current time plus 1 hour
to check again later.
|
getStatesgetAllowedTransitions, getDescription, getErrorState, getFailureTransitions, getInitialState, getMethod, getName, getSettings, getState, getSupportedSignals, getType, isAllowedNextAction, isStartState, permit, permit, setDescription, setNameequals, hashCode, toStringpublic static final String VAR_SCHEDULE
protected CronWorkflow(String type, WorkflowSettings settings)
public NextAction doWork(StateExecution execution) {
// do the work here
return NextAction.moveToState(schedule, "Work done");
}
type - The type of the workflow.settings - The workflow settings.protected CronWorkflow(String type)
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");
}
type - The type of the workflow.public NextAction schedule(StateExecution execution, String cron)
getNextActivationTime.execution - The workflow execution context.cron - The cron state variable.protected org.joda.time.DateTime getNextActivationTime(StateExecution execution, String cron)
execution - The workflow execution context.cron - The cron schedule.public NextAction handleFailure(StateExecution execution)
handleFailureImpl(io.nflow.engine.workflow.definition.StateExecution).execution - The workflow execution context.protected boolean handleFailureImpl(StateExecution execution)
execution - The workflow execution context.public NextAction waitForWorkToFinish(StateExecution execution)
waitForWorkToFinishImpl(io.nflow.engine.workflow.definition.StateExecution) to check if this instance should wait for work to finish or move to schedule state.execution - The workflow execution context.protected org.joda.time.DateTime waitForWorkToFinishImpl(StateExecution execution)
execution - The workflow execution context.Copyright © 2014–2021 Nitor Creations. All rights reserved.