See: Description
Interface | Description |
---|---|
BatchAdapter |
Interface
BatchAdapter allows an instance to be notified by the BatchManager of execution events
of a BatchJob. |
ExceptionBatchAdapter |
Class | Description |
---|---|
BatchJob |
Captures state information about batch jobs.
|
BatchManager |
Starts and completes BatchJobs.
|
ExceptionHandlingCompletedHandler | |
NullAdapter |
Poor mans implementation of
BatchAdapter . |
System steps (specified via system <methodname>) in WDL are for the automatic execution of methods. They are executed within the current thread and within the current transaction context. So the duration of a user initiated finish action of an interactive step is prolonged by the duration of the following system steps (and the duration of the preprocessing method of the next interactive step). As a consequence, system steps should be rather lightweight in terms of execution time.
Batch jobs are created in the process definition via the batch statement in WDL or in the process editor.
A timer activated BatchManager
is responsible for starting batch jobs and for finishing and continuing the execution of the process instance after a batch job has completed.
after the batch job has completed.
Batch jobs are instances of BatchJob
.
State information about batch jobs is maintained persistently in the database and
updated throughout the lifecyle of the job. Each job follows a lifecycle which is
normally a sequence of the four states
CREATED
,
STARTED
,
FINISHED
and
COMPLETED
.
Created means entered into the database but not (yet) started. Started means that the Batchjob is currently running. Finished batch jobs have terminated their execution, but the corresponding process step where the batch job originated is still not finished. After the originating stepinstance is finished, the job is said to be completed.
Lifecyle events can be captured by means of implementing the BatchAdapter
interface.
batch <batchAdapterClassname>([stringparam]) { startnow | newthread | retrystart | autofinish | pollfinish | gobackonerror }
e.g.: batch com.groiss.demo.DemoBatchAdapter("p1") startnow gobackonerror;
An appropriate BatchAdapter
must be stated, one constant parameter can be given and the behaviour
can be modified in six ways via flagging
afterCreation
bj.getParams
, the ActivityInstance can be accessed via
bj.getContext
If an exception occurs during the creation of the batch job, the action (the previously issued finish) is rolled back and no traces remain in the database.
After creation of the batch job, afterCreation
is called. This method can be used
to prepare the start of the batch job e.g. by transferring values from forms to some appropriate locations. If some fields of the
batch job instance are updated, then the update call for the batchjob in the database is the responsibility of afterCreation.
The call of afterCreation takes place in the same thread and transactional context as the previous finish. Exceptions thrown
by afterCreation cause rollback of the transaction.
doStart
doStart
is called.
If an exception is thrown in doStart, the batch system issues an rollback (since @enterprise version 9.0) and the state of the
BatchJob is changed to STARTERROR
.
markJobFinished
BatchManager.markJobFinished
.
When the BatchManager detects such jobs during its next timer controlled run, it completes them.
beforeCompletion
,
Completion and
afterCompletion
First, the beforeCompletion
method
is called.
If there is an exception, the job is placed in state FINISHERROR
.
No further action is taken by the batch system.
If all went well in beforeCompletion, the originating task of the process instance is finished and
the job is placed in state COMPLETED
.
If there is an exception during the finish,
the job is placed in state FINISHERROR
and
no further action is taken by the batch system.
After this, the
afterCompletion
method is called
with a boolean parameter which indicates if the job is now in state COMPLETED (commit = true) or in
state FINISHERROR (commit = false). Exceptions thrown by afterCompletion trigger a rollback (since @enterprise version 9.0).
doCompensate
doCompensate
is called.
ABORTED
.
No further action on this batch job will take place automatically.
If such a process is reactivated later on,
no changes are made to the state of the batch job. The administrator will have to make
the appropriate adjustments to the batch job manually via the link in the process history
(e.g. setting the state to STARTED
or to FINISHED
and to adjust the associated time stamps).
BatchJob.setStartnow(boolean)
,
BatchJob.setNewthread(boolean)
,
BatchJob.setRetryStart(boolean)
,
BatchJob.setAutofinish(boolean)
,
com.groiss.wf.batch.BatchJob#setPollfinish
and
BatchJob.setGoBackOnError(boolean)
or
in the third parameter of
BatchManager.submitJob
.
BatchManager.submitJob
method
and not during the next timer triggered run of the BatchManager.
doStart()
are handled differently.
An exception would lead to no change of the state of the batch job, it stays in CREATED
.
During the next run of the executing timer, a new start attempt will take place.
The code in doStart()
can also use one of the following methods to prevent further start attempts:
BatchManager.markJobError()
:
the job is placed in state STARTERROR.
BatchManager.markJobSuspendRetry()
:
the job is still in state CREATED, but no further start attempts are being made.
Using BatchManager.markJobRetry()
, further start attempts can be activated again.
STARTED
),
the job is marked as finished and then completed by the system itself.
doPoll()
method of the BatchAdapter
to determine if the job is finished. If doPoll()
BatchManager.markJobFinished()
, the batchJobs state is FINISHED and the batchjob and will be completed by the executing thread.
BatchManager.markJobError()
, the batchJos state is FINISHERROR.
BatchManager.markJobSuspendPoll()
, the state remains unchanged, and further poll attempts will be suspended.
The poll attempts can be activated again by calling BatchManager.markJobPoll()
.
The defaults for the lifecycle are startnow=false, newthread=false, retrystart=false, autofinish=false, pollfinish=false and gobackonerror=false. Using startnow=true, newthread=false, retrystart=false, autofinish=true, pollfinish=false, and gobackonerror=true, we approach the semantics of the system steps.
@enterprise 10.0.39049 Copyright © 2024 FREQUENTIS AG. All Rights Reserved.