Some of the use cases for `ExecutionStep` are as follows:
- Long Running Jobs: These are jobs that take several minutes or hours to execute.
- Multi-step Jobs: These are jobs which organise the execution through multiple logical steps (e.g.: transcode a file, then create Flex Asset and add Technical Metadata)
Using `ExecutionStep`, plugin developers can implement an `ActionExecutor` that delegates async behaviour via `ExecutionStep` active component.
- After `ActionExecutor.execute()` returns, `ExecutionStep.execute()` will be called periodically.
- The plugin will receive `ExecutionStepData` associated to the job context and can execute step logic to continue running / complete / fail / cancel the job.
JEF will use `ExecutionStep` to orchestrate and ease the development of above steps in independent classes
- The steps can be defined linearly, or could be a dynamic graph of options based on the logic of the plugin and current status.
- `ExecutionStep` can also be leveraged to reuse logic across multiple plugins, or orchestrate different flows depending on plugin logic or retry status.
Developing with ExecutionStep: simple example
- `ExecutionStepConfiguration` class is registered in the `ActionExecutor` annotation to indicate that this Action is using `ExecutionStep`.
- `ExecutionStepData` is a POJO required to store job execution data. It could be empty if no data is required across different execution step.
- `ExecutionStepData` is passed with every call to `ExecutionStep` to execute. This allows the job executor to resume in a different job executor microservice, in case one instance fails during the lifetime of the job.
- `ActionExecutor.execute(ExecutionStepData)` will be called first time to initiate the job execution
- `ExecutionStep.execte(ExectuionStepData)` implementation is called periodically during the life of the job.
Multiple functional steps
In addition to above simple example, a plugin developer can define multiple functional steps with the following implementation:
- `Class<StepExampleExecutionStep1> getExecutionStepClass().ExecutionStepConfiguration` defines which of all the existing ExecutionStep beans is the first one to start the execution.
- `Class<? extends ExecutionStep> ExecutionStep.getNextStep(StepExampleActionStepData actionStepData)` defines which is the next step to run based on stepData. Notice that this could be resolved based on dynamic logic.
This is all you need to organise your plugin execution into smaller, reusable functional components.