The ActionExecutor
class enables you to register the ActionProgress
plugin function with the specific logic, which is periodically called until the job terminates (Statuses are: COMPLETED, FAILED, CANCELLED).
Example:
@Componentf
@Scope("prototype")
@Slf4j
@PluginScope(value = PluginScopeType.DEVELOPMENT)
@ActionPlugin(uuid = "3ab237d4-0b19-4f01-8ded-396ee5444284", type = "smoke",
plugin = "async-smoke-action", version = "1.0.2",
actionConfiguration = AsyncSmokeActionConfiguration.class,
actionProgress = AsyncSmokeActionProgress.class,
actionProgressData = AsyncSmokeActionProgressData.class)
public class AsyncSmokeActionExecutor extends ActionExecutor
<AsyncSmokeActionConfiguration> {
…
ActionExecutor
is called for the first time using the following method to execute a job request:
@Override
@SneakyThrows
public ActionExecutorResponse execute(ActionProgressData actionProgressData) {
// logic to run the plugin for the first time
…
ActionExecutor.execute
(ActionProgressData) is responsible for the following:
Once the first call to ActionExecutor.execute
has been made, actionProgress
is subsequently called until the job completes, fails, or is cancelled using the following method:
@Override
public ActionExecutorMessage execute(Job job, DemuxProgressData progressData) {
ActionProgress.execute
(Job job, DemuxProgressData progressData) is responsible for the following:
ActionProgress.execute(...)
plugin.ActionExecutorResponse
with a “Completed” state.ActionProgress.execute(...)
will be called until a terminal state is achieved (Statuses are: COMPLETED, FAILED, CANCELLED).
By responding to the ActionProgress.execute(...)
the job is kept running.
If ActionProgress.execute(...)
is not called, the watcher running periodically in the JEF service will be marked as TIMED_ OUT.
JEF includes a watcher mechanism, which moves jobs to a TIMED_OUT state if they don’t return after a certain period of time. This watcher can be disabled for each service type if necessary.
The configuration shown above is optional. If an action plugin doesn’t configure the actionProgress, the plugin is expected to terminate as part of the ActionExecutor.execute(..)
when the first call is made:
<pre class="pre codeblock hljs sql">
@Override
@SneakyThrows
public ActionExecutorResponse execute(ActionProgressData actionProgressData) {
// logic to run first time plugin is called
…
## ActionProgressData: Maintaining Data Across Different Calls to ActionProgress.execute(...)
JEF 7.0.0 comes with a mechanism to help you maintain data across different `ActionProgress.execute` iterations.
**Example:**
@Component @Scope(“prototype”) @Slf4j @PluginScope(value = PluginScopeType.DEVELOPMENT) @ActionPlugin(uuid = “3ab237d4-0b19-4f01-8ded-396ee5444284”, type = “smoke”, plugin = “async-smoke-action”, version = “1.0.2”, actionConfiguration = AsyncSmokeActionConfiguration.class, actionProgress = AsyncSmokeActionProgress.class, actionProgressData = AsyncSmokeActionProgressData.class)
* The optional `actionProgressData` attribute configures a plugin so that it can host data contexts for different runs of `ActionProgress.execute(...)`
* When the ActionExecute.execute(...) starts and the `actionProgressData` attribute has been configured, a new instance of this class is provided to the execute method.
* Developers can use this POJO (plain old java object) to keep the context of the job execution until the job finishes.
* The `actionProgressData` attribute uses the latest state for every call to the `ActionProgress.execute(...)`.
* The `actionProgressData` attribute is serialised (JSON to Redis) with the state values for each call.
## Final Call to the ActionProgress Methods
`onCompleted`, `onCancel`, or `onFailed` will be called after the ActionProgress.execute(...) changes the state to one of these terminal states.
Developers should not change the job status at this point, as the job has been terminated and propagated to the original Enterprise client. This method gives the developer the option to add any required logic before the ActionExecutor is finally discarded.